SheetX Document
1. Introduction
This tool simplifies database design and management for game developers and designers, allowing for easy modification of configurations and statistics.
As projects grow, the need for efficient management of data tables, constants, and IDs increases. This tool centralizes the process, enabling easy searching, modification, and updates.
It supports various data types and utilizes popular spreadsheet tools for data management.
You can download Example Here
2. Main functions
- Excel and Google Sheets Integration: Manage your entire database using Excel or Google Spreadsheets.
- ID and Constant Management: Make batch adjustments to IDs and constants without impacting the database.
- Localization System: Effortlessly handle multiple languages, with seamless Unity integration.
- JSON Export: Convert data tables to JSON files for easy Unity integration.
- Flexible Data Formats: Support a variety of data formats, adaptable to your design needs.
3. Settings
Navigate to the main menu and select: Window > SheetX > Settings
- Scripts Output Folder: Stores exported C# scripts, including IDs, Constants, Localization Components, and Localization API.
- Json Output Folder: Stores exported JSON data.
- Localization Output: Stores Localization Data, which should be inside the Resources folder for loading via Resources, or in the Localizations folder for loading via Addressable Asset System.
- Namespace: Defines the namespace for the exported C# files.
- Separate IDs: Sheets
- TRUE: Exports [%IDs] sheets to individual C# files named [SheetName] + IDs.cs.
- FALSE: Merges all [%IDs] sheets from all Excel files into a single C# file named IDs.cs.
- Separate Constants: Sheets
- TRUE: Exports [%Constants] sheets to individual C# files named [SheetName] + %Constants.cs.
- FALSE: Merges all [%Constants] sheets from all Excel files into a single C# file named Constants.cs.
- Separate Localization Sheets:
- TRUE (default): Exports [Localization%] sheets to separate groups, each containing Localization Data, Component, and API, with the following file name structure:
- Localization Data: [SheetName]_[language].txt
- Component: [SheetName] + Text.cs
- API: [SheetName].cs
- FALSE: Merges all [Localization%] sheets from all Excel files into a single group, with the following file name structure:
- Localization Data: Localization_ + [language].txt
- Component: LocalizationText.cs
- API: Localization.cs
- TRUE (default): Exports [Localization%] sheets to separate groups, each containing Localization Data, Component, and API, with the following file name structure:
- Only enum as IDs: For [%IDs] sheets, columns with the extension [enum] will be exported as enums and will not include the Integer Constant form.
- Combine Json Sheets: Merges the Data Table from one Excel file into a single JSON file, named [ExcelName].txt.
- Language Char Sets: Used in Localization with TextMeshPro to compile the character table of a language, mainly applied for Korean, Japanese, and Chinese due to their extensive character systems.
- Persistent columns: Specifies the names of columns to retain during processing even if they are empty.
- Google Client ID: Enter your Google Client ID (retrieved from Credentials in Google Console).
- Google Client Secret: Enter your Google Secret (retrieved from Credentials in Google Console).
4. Excel Sheets Exporter
4.1. Export Single Excel File
Navigate to the main menu and select: Window > SheetX > Excel Spreadsheets
This function is ideal for learning how to use the tools. It’s great for small, simple Static Databases that only need one Excel file for all the data.
Key Functions:
- Export IDs: Converts ID sheets to C# files.
- Export Constants: Converts Constants sheets to C# files.
- Export Json: Transforms Data Table sheets into JSON data.
- Export Localization: Exports Localization Data, Localization Components, and Localization API.
- Export All: Performs all the functions with a single click.
4.2. Export multiple Excel Files
This feature is essential for managing complex Static Databases divided into multiple Excel files. It helps you efficiently handle and export all your files with one click:
- Add all the Excel files you want to process.
- For each Excel file, you have the option to choose which sheets to include or exclude.
- Press the Export All button to complete the process.
5. Google Spreadsheets
Prefer using Google Spreadsheets? No problem.
Navigate to the main menu and select: Window > SheetX > Google Spreadsheets
5.1. Setup Google Client ID and Client Secret
Copy the Client ID and Client Secret, and paste them into the corresponding settings in the Sheets Exporter Settings Window
5.2. Export single Google Spreadsheet
Enter the Google Sheet ID, then click the Download button. You can find the ID in the Google Sheet’s URL, formatted like this:
https://docs.google.com/spreadsheets/d/[GOOGLE_SHEET_ID]/edit?......
5.3. Export multiple Google Spreadsheets
Click on Add Google Spreadsheets, then enter the Google Sheet ID in the popup that appears. Press Download, then select the sheets you want to process.
6. Rules in Spreadsheet
6.1. IDs
Hero | Building | Pet | Gender[enum] | |||||||
---|---|---|---|---|---|---|---|---|---|---|
HERO_1 | 1 | comment | BUILDING_NULL | 0 | comment | PET_NULL | 0 | comment | GENDER_NONE | 0 |
HERO_2 | 2 | comment | BUILDING_1 | 1 | PET_1 | 1 | GENDER_MALE | 1 | ||
HERO_3 | 3 | comment | BUILDING_2 | 2 | PET_2 | 2 | GENDER_FEMALE | 2 | ||
BUILDING_3 | 3 | PET_3 | 3 | GENDER_HELICOPTER | 3 | |||||
BUILDING_4 | 4 | PET_4 | 4 | |||||||
BUILDING_5 | 5 | PET_5 | 5 | |||||||
BUILDING_6 | 6 | PET_6 | 6 | |||||||
BUILDING_7 | 7 | PET_7 | 7 | |||||||
BUILDING_8 | 8 |
ID Sheets, named with the suffix IDs
are used to compile all IDs into Integer Constants. The design rules are:
- The sheet name must end with
IDs
. - Only the Integer data type is allowed.
- Each group is organized in 3 consecutive columns.
- The first row contains the group name for easy reference.
- The first column holds the Key Name, and the next column holds the Key Value.
- Key Value must be an integer.
- By default, all IDs in a column will be exported as Integer Constants. Add the suffix [enum] to the group name to export them as an enum.
- To only export enums and skip Integer Constants, select
Only enum as IDs
in the Settings.
| Group | Key | Comment |
| ----- | --- | ------- |
6.2. Constants
Name | Type | Value | Comment |
---|---|---|---|
EXAMPLE_INT | int | 83 | Integer Example |
EXAMPLE_FLOAT | float | 1.021 | Float example |
EXAMPLE_STRING | string | 321fda | String example |
EXAMPLE_INT_ARRAY_1 | int-array | 4 | Integer array example |
EXAMPLE_INT_ARRAY_2 | int-array | 0:3:4:5 | Integer array example |
EXAMPLE_FLOAT_ARRAY_1 | float-array | 5 | FLoat array example |
EXAMPLE_FLOAT_ARRAY_2 | float-array | 5:1:1:3 | FLoat array example |
EXAMPLE_VECTOR2_1 | vector2 | 1:2 | Vector2 example |
EXAMPLE_VECTOR2_2 | vector2 | 1:2:3 | Vector2 example |
EXAMPLE_VECTOR3 | vector3 | 3:3:4 | Vector3 example |
EXAMPLE_REFERENCE_1 | int | HERO_1 | Integer example |
EXAMPLE_REFERENCE_2 | int-array | HERO_1 : HERO_2 | Integer array example |
EXAMPLE_REFERENCE_3 | int-array | HERO_1 | HERO_3 | Integer array example |
EXAMPLE_REFERENCE_4 | int-array | HERO_1 HERO_4 | Integer array example |
EXAMPLE_FORMULA_1 | int | =1*10*36 | Excel formula example |
EXAMPLE_FORMULA_2 | float | =1+2+3+4+5+6+7+8+9 | Excel formula example |
Constants Sheets, named with the suffix Constants
compile project constants. The design rules are:
- The sheet name must end with
Constants
. - There are four columns: Name, Type, Value, and Comment.
- Name: The name of the constant; must be continuous, without special characters.
- Type: The data type of the constant. Possible data types include:
int
,float
,bool
,string
,int-array
,float-array
,vector2
, andvector3
. - Value: The value matching the data type. For array types, separate elements with
:
or|
ornewline
.
| Name | Type | Value | Comment |
| ---- | ---- | ----- | ------- |
6.3. Localization
idstring | relativeId | english | spanish |
---|---|---|---|
message_1 | this is english message 1 | este es el mensaje en ingles 1 | |
message_2 | this is english message 2 | este es el mensaje en ingles 2 | |
message_3 | this is english message 3 | este es el mensaje en ingles 3 | |
content | 1 | this is english message 1 | este es el mensaje en ingles 1 |
content | 2 | this is english message 2 | este es el mensaje en ingles 2 |
content | 3 | this is english message 3 | este es el mensaje en ingles 3 |
title_1 | this is english title 1 | este es el titulo 1 en ingles | |
title_2 | this is english title 2 | este es el titulo 2 en ingles | |
title_3 | this is english title 3 | este es el titulo 3 en ingles | |
whatever_msg | this is a sample message | este es un mensaje de muestra | |
hero_name | HERO_1 | hero name 1 | nombre del héroe 1 |
hero_name | HERO_2 | hero name 2 | nombre del héroe 2 |
hero_name | HERO_3 | hero name 3 | nombre del héroe 3 |
Localization Sheets are named with the prefix Localization
and follow these rules:
- TThe sheet name must start with
Localization
. - Each sheet has two key columns: the main key
idString
and an additional keyrelativeId
. - The following columns contain localized content.
- The key for each row is a combination of
idString
andrelativeId
. relativeId
can reference an ID from the IDs sheets.
| idString | relativeId | english | spanish | japan | .... |
| -------- | ---------- | ------- | ------- | ----- | ---- |
6.4. Data table - JSON Data
Basic data type: Boolean, Number, String
numberExample1 | numberExample2 | numberExample3 | boolExample | stringExample |
---|---|---|---|---|
1 | 10 | 1.2 | TRUE | text |
2 | 20 | 3.1 | TRUE | text |
3 | BUILDING_8 | 5 | FALSE | text |
6 | HERO_3 | 10.7 | FALSE | text |
9 | PET_2 | 16.4 | FALSE | text |
Extended data type: Array, JSON object
array1[] | array2[] | array3[] | array4[] | array5[] | array6[] | JSON{} |
---|---|---|---|---|---|---|
text1 | 1 | 1 | TRUE | 123 66 |
aaa ccc |
{} |
text2 | 2 | 2 | 3 | 1 | 2 | 3 | TRUE | FALSE | TRUE | 123 71 |
aaa ccc |
{“id”:1, “name”:”John Doe 1”} |
text1 | text2 | 1 | 2 | 1 | BUILDING_2 | TRUE | FALSE | 123 67 |
aaa ccc |
{“id”:2, “name”:”John Doe 2”} |
text1 | text2 | text3 | 1 | 2 | 3 | BUILDING_1 | HERO_2 | TRUE | FALSE | TRUE | 123 68 |
aaa ccc |
{“id”:HERO_2, “name”:”JohnDoe 2”} |
text3 | 4 | 2 | BUILDING_3 | HERO_1 | HERO_2 | TRUE | FALSE | 123 76 |
aaa ccc |
[{“id”:HERO_1, “name”:”John Doe 1”},{“id”:HERO_2, “name”:”Mary Sue 2”}] |
text1 | text2 | text7 | 5 | 1 | 2 | 4 | PET_5 | TRUE | 123 78 |
aaa ccc |
[{“id”:HERO_1, “name”:”John Doe 1”},{“id”:HERO_2, “name”:”Mary Sue 2”}] |
- For array types, the column name must end with
[]
. - For JSON object types, the column name must end with
{}
.
Special data type: Attributes list
attribute0 | value0 | unlock0 | increase0 | max0 | attribute1 | value1[] | unlock1[] | increase1[] | max1[] | … | attributeN |
---|---|---|---|---|---|---|---|---|---|---|---|
ATT_HP | 30 | 2 | 1.2 | 8 | … | ||||||
ATT_AGI | 25 | 3 | 1.5 | 8 | … | ||||||
ATT_INT | 30 | 2 | 1 | 5 | ATT_CRIT | 3 | 2 | 0 | 11 | 0.5 | 1 | 10 | 20 | … | |
ATT_ATK | 30 | 2 | 1 | 8 | ATT_CRIT | 10 | 1 | 1 | 12 | 1.5 | 1 | 10 | 20 | … | |
ATT_CRIT | 10 | 1 | 1 | 12 | 1.5 | 1 | 10 | 20 | … |
Attribute is a specific data type, specially created for RPG genre games - where characters and equipment can possess various different and non-fixed attributes and stats. This data type makes character and equipment customization more flexible, without restrictions.
To define an attribute object type, the following rules should be followed:
- The attribute columns should be placed at the end of the data table.
- Attribute id is a constant integer, so it should be defined in the IDs sheet.
-
An attribute has the following structure:
attribute
: The column name follows the patternattribute + (index)
, where index can be any number, but should start from 0 and increase. The value of this column is the id of the attribute, which is an Integer type, this value should be set in the IDs sheet.value
: The column name follows the patternvalue + (index)
orvalue + (index) + []
, the value of the column can be a number or a number array.increase
: The column name follows the patternincrease + (index)
orincrease + (index) + []
. This is an additional value, which can be present or not, usually used for level-up situations, specifying the additional increase when a character or item levels up.unlock
: The column name follows the patternunlock + (index)
orunlock + (index) + []
. This is an additional value, which can be present or not, usually used for situations where the attribute needs conditions to be unlocked, such as minimum level or minimum rank.max
: The column name follows the patternmax + (index)
ormax + (index) + []
. This is an additional value, which can be present or not, usually used for situations where the attribute has a maximum value.
Example 1: attribute0, value0, increase0, value0, max0. Example 2: attribute1, value1[], increase1[], value1[], max1[].
7. How to integration
Download and import the Example
First, open the excel file located at /Assets/SheetX/Examples/Exporting a Single Excel/Example.xlsx
. This is a sample Excel file. Within this file, there are sheets containing sample data that will help you understand how to design various types of data such as IDs, Constants, and Data Tables.
For the example using Google Sheets, you can view the file here.
Example for exporting single file Example
Example for exporting multiple files Example 1 Example 2 Example 3 Example 4
7.1. Create folders for exporting files
Create 3 directories to store the files that will be exported:
- A folder to store the C# scripts (IDs, Constants, Localization Component, Localization API).
- A folder to store the JSON data files.
-
A folder to store the Localization data.
- There are two ways to set up the folder for Localization data, depending on how you want to load Localizations:
- The easiest method is to load from the Resources folder. Create a folder inside the Resources folder to store Localization data. You can name this folder anything you like.
- Alternatively, use the Addressable Asset System. In this case, create a “Localizations” folder outside the Resources folder and set it as an Addressable Asset. It’s recommended to name this folder “Localizations”.
- There are two ways to set up the folder for Localization data, depending on how you want to load Localizations:
- Navigate to
Window > SheetX > Settings
- In Sheets Exporter Settings, set up the paths for the “Scripts Output Folder,” “Json Output Folder,” and “Localization Output Folder” using the three folders you just created.
For this example I will create 3 folders:
Assets\SheetXExample\Scripts\Generated
: for C# scriptsAssets\SheetXExample\DataConfig
: for Json dataAssets\SheetXExample\Resources\Localizations
: for Localization data
7.2. Scripting
Create a ScriptableObject as Storage for Static Database
- Create Serializable classes that correspond to the data fields in the data tables.
[Serializable]
public class ExampleData1
{
public int numberExample1;
public int numberExample2;
public float numberExample3;
public bool boolExample;
public string stringExample;
}
[Serializable]
public class ExampleData2
{
[Serializable]
public class Example
{
public int id;
public string name;
}
public string[] array1;
public int[] array2;
public int[] array3;
public bool[] array4;
public int[] array5;
public string[] array6;
public Example json1;
}
[Serializable]
public class ExampleData3
{
public int id;
public string name;
public List<Attribute> Attributes;
}
[Serializable]
public class Attribute
{
//=== MAIN
public int id;
public float value;
public int unlock;
public float increase;
public float max;
//=== Optional
public float[] values;
public float[] increases;
public float[] unlocks;
public float[] maxes;
}
- Create a ScriptableObject to encapsulate the above Serializable classes.
[CreateAssetMenu(fileName = "ExampleDataCollection", menuName = "SheetXExample/Create ExampleDataCollection")]
public class ExampleDataCollection : ScriptableObject
{
public List<ExampleData1> exampleData1s;
public List<ExampleData2> exampleData2s;
public List<ExampleData3> exampleData3s;
}
- Load Json Data into Serializable classes
// NOTE: This function utilizes the UnityEditor library and must be placed in the Editor directory or within #if UNITY_EDITOR directives.
// If you prefer not to use Editor code, you can alternatively store the JSON data files in the Resources directory or Asset Bundles and load them accordingly.
[ContextMenu("Load")]
private void LoadData()
{
#if UNITY_EDITOR
var txt = AssetDatabase.LoadAssetAtPath<TextAsset>("Assets/Import/Json/ExampleData1.txt");
exampleData1s = JsonConvert.DeserializeObject<List<ExampleData1>>(txt.text);
txt = AssetDatabase.LoadAssetAtPath<TextAsset>("Assets/SheetXExample/DataConfig/ExampleData2.txt");
exampleData2s = JsonConvert.DeserializeObject<List<ExampleData2>>(txt.text);
txt = AssetDatabase.LoadAssetAtPath<TextAsset>("Assets/SheetXExample/DataConfig/ExampleData3.txt");
exampleData3s = JsonConvert.DeserializeObject<List<ExampleData3>>(txt.text);
#endif
}
7.3. Localization integration
- Initialization
LocalizationManager.Init();
- Change the language.
// Set the language japanese
LocalizationsManager.CurrentLanguage = "jp";
- Register an event handler for the language change event.
// Register an action when language changed
LocalizationsManager.OnLanguageChanged += OnLanguageChanged;
-
You can retrieve localized content using three different methods.
-
Retrieve localized content using a Key. Note that the text will not automatically refresh when the language changes using this method.
// Retrieve localized text using an integer key m_simpleText1.text = LocalizationExample2.Get(LocalizationExample2.GO_TO_SHOP).ToString(); // Retrieve localized text using an integer key with an argument m_simpleText2.text = LocalizationExample2.Get(LocalizationExample2.REQUIRED_CITY_LEVEL_X, 10).ToString(); // Retrieve localized text using a string key with an argument m_simpleText3.text = LocalizationExample2.Get("REQUIRED_CITY_LEVEL_X", 25).ToString();
-
Link a GameObject containing a Text or TextMeshProUGUI component with a key so that the text automatically updates when the language changes.
// Register dynamic localized text using an integer key LocalizationExample2.RegisterDynamicText(m_dynamicText1.gameObject, LocalizationExample2.TAP_TO_COLLECT); // Register dynamic localized text using an integer key with an argument LocalizationExample2.RegisterDynamicText(m_dynamicText2.gameObject, LocalizationExample2.REQUIRED_LEVEL_X, "3"); // Register dynamic localized text using a string key with an argument LocalizationExample2.RegisterDynamicText(m_dynamicText3.gameObject, "REQUIRED_LEVEL_X", "30");
// Unregister the gameObject Localization.UnregisterDynamicText(m_textGameObject1); Localization.UnregisterDynamicText(m_textGameObject2); Localization.UnregisterDynamicText(m_dynamicText3);
-
Using Localization Component.
-
Combine Localizations
If you want to combine all Localization Sheets, simply deselect the “Separate Localization Sheets” checkbox in the Settings. Next, delete all generated files and re-export everything.
Then, replace instances of LocalizationExample1 and LocalizationExample2 with Localization. Also, replace component LocalizationExample1Text and LocalizationExample2Text with LocalizationText.
Creating TextMeshPro Fonts for Different Languages
To create TextMeshPro fonts for Japanese, Korean, and Chinese, follow these steps using the respective character set files characters_set_jp, characters_set_ko, and characters_set_cn, which include all characters from the localization sheets:
Fonts to use in this example:
- Japanese: NotoSerif-Bold
- Korean: NotoSerifJP-Bold
- Chinese: NotoSerifTC-Bold
Creating TextMeshPro Fonts:
- For each language font, create a TextMeshPro font asset.
- Open the Font Asset Creator window in Unity.
- Under the Character Set section, select Character From File.
- Choose the appropriate character set file (e.g., characters_set_jp) in the Character File section.
Loading Localization Using the Addressable Assets System
To utilize this feature, follow these steps:
- Install the Addressable Assets System.
- Add
ADDRESSABLES
to the directives list in the Build Settings. - Move the Localizations folder out of the Resources folder. Additionally, relocate the Output folder in the SheetX Settings window.
- Set the Localizations folder as an Addressable Asset.