[RELEASED] Unity-QuickSheet

Unity-QuickSheet enables you to use google and excel spreadsheet data within Unity editor. With Unity-QuickSheet, you can retrieve data from a spreadsheet and save it as an asset file with a scriptableobject format even without writing single line of code.

You can find Unity-QuickSheet on github:

https://github.com/kimsama/Unity-QuickSheet

Features

  • No need to write any single line of code.
  • It can retrieve data from excel file. (both of xls and xlsx format are supported.)
  • It can retrieve data from google spreadsheet.
  • No need to write a parser to retrieve data, it automatically serializes retrieved data into Unity3D’s ScriptableObject, the binary format and so it is fast than to use XML which is usually ASCII format.

New

  • Bunch of documentation are updated (2017.01.29). See that on GitBook site, can be found on here.
  • v.1.0.0.0 is released. See the release note.

Say again, you don’t need to write even single line of code!

Enjoy!

1 Like

Thanks! I needed something like this and working perfectly in Unity 5 :slight_smile:

This is a great. Thank you so much for sharing.

Sorry to be such a newbie, but could you possibly provide a simple code example of how to retrieve data from the generated script files? It’s not clear from your howto docs, why the four files are generated (2 in the Editor folder and 2 in the Runtime folder), or how and when to use each one.

i.e. to populate a UI text object with data from my spreadsheet, which ScritableObject do I parse through…
your-sheetpag-name.cs or your-sheetpage-nameData.cs ?
And does this have to be done twice (the Runtime version and the Editor version, so that the data appears both at runtime and in the editor?)

A simple example project would be very much appreciated!

Thank you for your interesting.

I assume you’ve already know how to get data from excel and make it to an .asset file.

Let me show you the very simple and easiest way to retrieve data from the extracted asset file. As you’ve mentioned, you have four generated files, two of them are under Editor folder and other of are any runtime folder you’ve specified in the setting.

Let’s say that you have Item worksheet in the excel file then you will get two generated script files, one is Item.cs and the other is ItemData.cs

public AssetLoader : MonoBehaviour { // It's ScriptableObject derived class which is generated under any runtime folder you've specified in the setting. // Drag .asset file onto 'item' member field from project view to Inspector view as any normal prefab file. public Item item void Start() { // Retrieves the first row ItemData itemData = item.dataArray[0]; Debug.LogFormat("Item Name: {0} Price: {1}", itemData.Name, itemData.Price); } } 

That’s all. :slight_smile:

All of data are automatically loaded when AssetLoader class instance is created like the same way of what Unity does for a prefab. You don’t need to write even a line of code to load .asset data.

One more thing keep in mind that. Instead of directly accessing to the data as the above code snip, I highly recommend to use LINQ to query.

Best,

-Kim

Looks cool! Any way to enter data for things like sprites or audio clips? I suppose you could just enter the Resource folder path where the asset is located.

Thanks and exactly you right. You need to just set a path for assets. The path can be either Resources or assetbundle’s are possible.

Cheers,

-Kim

Can I use this to post data to the google spreadsheet?

No, it does not support to post data send back to google’s spreadsheet.

See the FAQ.

Im not getting more than two columns of data from the spreadsheet, i created a test project and everything went fine. But it’s not importing data of more than 2 columns, am I missing something?


2836100--206852--unity.PNG

Hmm… it strange. The spreadsheet looks like fine.

Did you check that all settings are ok, every setting of types of the column?

Is there any log on the console?

I restarted unity and tried it again, with the same results. The logs are saying successfully generated.

Could you share the spreadsheet? So let me check it on my side.

Thanks for making this… :slight_smile:
I’m also testing this currently and getting missing cell content…also I can’t see seem to get the array work. In the end I was hoping for that putting in text with line breaks into a cell would give me an array…something like ā€œSentence on 1, Sentence 2ā€¦ā€ but don’t know if that is supported behaviour?

I have also tried now using comma to separate, which actually do give me an array…although as my intended content is a sentence… there can be commas in it.

Cheers

Stefan

You should use ā€˜,’(comma) to separate array elements not new-line delimiter.

Modify the cell:
Text Line 1, Text Line2

By the way it looks so strange of missing ā€˜Field_ID’ column. Remove any new-line break (if anything is there) and download it again.

Yeah just noticed that…as I got it to work…but yeah in my case I have to use commas I wont be able to use this…unless I can modify it to support multiline text fields. Will try cleaning up and see if it populates all the fields…

If you want to new-line delimiter instead of comma, you need to modify code for yourself.

See the Assets\QuickSheet\GDataPlugin\Editor\GDataDB\GDataDB\Impl\Serializer.cs file and find Deserialze function.

 public T Deserialize(ListEntry e) { var t = typeof (T); ... try { if (property.PropertyType.IsArray) { const char DELIMETER = ','; // '\n' // HERE!, changing ',' to '\n' is what you want. ... 

Note that change of the above only valid on google spreadsheet not for excel file.

Cheers,

Ahh cheers…there it is :slight_smile: So he spreadsheet was clean…it was just the cell alignment on the other cells…tried changing the delimiter

"const char DELIMETER = ā€˜\n’;

but no luck…maybe might line ending type issues here…I’m running on mac…and then I guess there is how it is treated on the google side… =O

…and we have lift off… :slight_smile:

Got it working when I bypassed the processing of the cell content string a few lines down:

 // remove whitespace between each of element string str = c.Value.ToString();//new string(c.Value.ToCharArray() // .Where(ch => !Char.IsWhiteSpace(ch)) // .ToArray()); // remove ',', if it is found at the end. char[] charToTrim = { ',', ' ' }; str = str.TrimEnd(charToTrim); // split by ',' object[] temp = str.Split(DELIMETER); Array array = (Array)Activator.CreateInstance(property.PropertyType, temp.Length); for (int i = 0; i < array.Length; i++) { array.SetValue(Convert.ChangeType(temp[i], property.PropertyType.GetElementType()), i); } property.SetValue(r, array, null); 

So now the issue with missing field content is the only hurdle…

Oh, you’re working on Mac machine.

On OSX, not likely on Windows, you should check either carriage-return, ā€˜\r’ after ā€˜\n’

So the line should be changed like the following:

const char DELIMETER = '\n\r'; 

Cheers,

ps. Some others prefer to use newline-breaker instead of using comma for array type. It may be better to set delimiter on somewhere in the configure file so the user determine and set the delimiter for their own. I’ll consider it later.

Yeah it would be nice if it would be possible to choose delimiter for each field, that would go nicely into the inspector where one declares type and if it is an array. :slight_smile:

As the multiline fields work…there is only the issue with the missing content in the ā€œField_IDā€ field…any ideas what could be causing this?

It could be the same issue as the previous user has…as I’ve used it successfully with a table with only two columns…and this one has more than 2… =O