[펌] Unity Excel Importer
unity-excel-importer-master.zip
Unity Excel Importer
Automatically import from xls, xlsx to custom ScriptableObject in Unity Editor
Import Setup
1. Create Excel and add to Unity
Create an Excel file, make the first row the name of the column, and enter the data from the second row. And add it to Unity’s Project view.
2. Create Entity Class Script
Create a new script and define a class with Excel column names and public fields of the desired type. Also give the class ‘System.Serializable’ attribute.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class MstItemEntity
{
public int id;
public string name;
public int price;
}
3. Create Excel Asset Script
After selecting Excel, execute ExcelAssetScript from the Create menu and create a ScriptableObject script for Excel.
As for the generated script, the Excel file name and the sheet name are extracted and the part is commented out as below.
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[ExcelAsset]
public class MstItems : ScriptableObject
{
//public List<EntityType> Entities; // Replace 'EntityType' to an actual type that is serializable.
}
4. Replace EntityType in created Excel Asset
Uncomment fields and replace the generic type of List with the Entity class defined above.
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[ExcelAsset]
public class MstItems : ScriptableObject
{
public List<MstItemEntity> Entities;
}
4. Reimport or re-save Excel
When you import or re-save Excel, a ScriptableObject with the same name as Excel is created in the same directory and the contents of Excel are imported.
After this setting, updating Excel automatically updates ScriptableObject as well.
Advanced
Comment Row
If you enter ‘#’ in the first cell of the row, you can treat it as a comment and skip.
Change Asset Path
You can change the ScriptableObject generation position by specifying AssetPath as the ExcelAssetAttribute as shown below.
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[ExcelAsset(AssetPath = "Resources/MasterData")]
public class MstItems : ScriptableObject
{
public List<MstItemEntity> Entities;
}
Use Enum
You can use enum by entering the element name as string in cell. It is also useful to set Data Validation pull down as an element of enum in Excel.
Lisence
This library is under the MIT License. This software includes the work that is distributed in the Apache License 2.0.
'Unity3D > Plugins' 카테고리의 다른 글
[펌] Socket.io-Client for Unity3D 소개 (0) | 2019.03.08 |
---|---|
[링크] iOSPlugin Sample (0) | 2019.01.29 |
[링크] Emoji_Extension (0) | 2018.06.07 |
[펌] Background Worker for Unity3D (0) | 2018.06.01 |
[Link] UnityAppNameLocalizationForIOS (0) | 2018.03.27 |