Skip to content

petereichinger/Unity-QuickSheet

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

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 on Windows, only xls on OSX.)
  • 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.

Saying again, you don't need to write even single line of code!

Getting Started

Usage

  • Using LINQ with QuickSheet
  • Enum with QuickSheet
  • NGUI localization with QuickSheet
  • Automation of formula calculation

Using Array type with QuickSheet

You can use array type with comma sperated values in a cell as the following:

Array type

Note that don't miss the last comma which should be after a last value in a cell.

1,2,3,4,5, -> Don't miss the comma right after '5' if not, the value '5' will not imported to an asset file.

After importing with the given excel file, specify type of each column-header and check array option for an array type.

Array type setting

It will generate array type memeber field of a data class with the specified type as the following code:

	[SerializeField]
	int[] intarray = new int[0];
	
	[ExposeProperty]
	public int[] Intarray { get {return intarray; } set { intarray = value;} }
	
	[SerializeField]
	string[] stringarray = new string[0];
	
	[ExposeProperty]
	public string[] Stringarray { get {return stringarray; } set { stringarray = value;} }

Using Enum type with QuickSheet

Specify enum type for a data class is easy. Let's say that you want to set enum type for 'RareType' on a spreadsheet as the following:

Enum type

The 'RareType' only can have one of value from three type which are Normal, Rare and Legend.

Because QuickSheet can not generate enum itself, you should first declare an enum type before generating script files.

Create an empty .cs file which usually contains various enums then declare 'RareType' enum type what for you've set on the spreadsheet.

public enum RareType
{
	Normal,
	Rare,
	Legend,
}

Now you can generate necessary script files without an error!

Add QuickSheet via subtree

You can add QuickSheet via subtree to your github project like the following:

git subtree add --prefix=Assets/QuickSheet https://github.com/your_github_account/your_project.git QuickSheet 

It creates QuickSheet folder under Assets unity project folder then put all the neccessary files under the QuickSheet folder.

Any changes for the remote repository easily can pull with git subtree pull as the following:

git subtree pull --prefix=Assets/QuickSheet https://github.com/kimsama/Unity-QuickSheet.git QuickSheet 

Setting up OAuth2 for accessing Google Drive

Google has changed the authentication scheme since May 5, 2015. Now it requires OAuth2. To set this up visit http://console.developers.google.com , create a new project, enable the Drive API, create a new client ID of type "service account" and download json file.

Tips

Excel

  • Keep as small number of sheet in one excel file. Let's consider a case that an excel file which contains over twenty sheet in one excel file and you've generated all ScriptableObject asset files for each sheet. And you've created a new sheet in the same excel file then try to generate necessary script files. What happens? Even you've created only one sheet and want to only import data into the new one but Quicksheet try to reimport all data from all sheets because querying data from excel into newly created ScriptableObject done by Unity's reimport. So keep in mind that working with an excel file which has too much sheets can be slow.

Limitations

  • ScritableObject does not allow to save data changed on runtime. So if you need to serialize and save things that changes on runtime, you need to look at other methods of serialization such as JSON, BSON or XML, depending on your platform and/or requirements.

  • Excel versions 97/2000/XP/2003 are suppported for .xls (Note that NPOI of Unity-QuickSheet does not support Excel versions 5.0/95 for .xls)

  • Google Spreadsheet plugin does not work in the Unity web player's security sandbox. You should change the Platform to 'Stand Alone' or something else such as 'iOS' or 'Android' platform in the Unity's Build Setting.

References

  • Unity Serialization on Unity's forum for details of serialization mechanism.
  • GDataDB is used to retrieve data from Google Spreadsheet. Note that GDataDB is slightly modified to support enum type.
  • ExposeProperties is used to easily expose variables of spreadsheet on the Unity3D's inspector view and let GDataDB access through get/set accessors.
  • NPOI is used to read xls and xlsx file.
  • All "*.dll" files of Google Data SDK are available at Google Data API SDK
  • Newtonsoft.Json source code for net 2.0 is available at here
  • Unity-GoogleData, my previous effort to import a spreadsheet data to Unity.

License

This code is distributed under the terms and conditions of the MIT license.

Some codes are borrowed from GDataDB and ExposeProperties. The license of the that follow theirs.

Copyright (c) 2013 Kim, Hyoun Woo

About

Unity-QuickSheet enables you to use spreadsheet file data within Unity editor.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 100.0%