我正在尝试使用UnityEngine.JsonUtility. 它工作正常,但我的枚举类型没有得到正确转换。我尝试使用该EnumMember属性,但仍然没有运气。
我该如何解决?
笔记
我正在使用此解决方案读取多个文件并将它们存储在数组中。
[Serializable]
public class EquipementItem
{
public enum ItemTypes
{
None,
Armor,
Weapon
}
public enum SlotTypes
{
Head,
Shoulders,
Chest,
Bracers,
Gloves,
Waist,
Legs,
Boots,
Weapon
}
public int ID;
public string Name;
public ItemTypes ItemType;
public SlotTypes SlotType;
}
Run Code Online (Sandbox Code Playgroud)
和 json 文件
{
"Items": [
{
"ID": "1",
"Name": "Basic Sword",
"ItemType": "Weapon",
"SlotType": "Weapon"
},
{
"ID": "2",
"Name": "Advanced Sword",
"ItemType": "Weapon",
"SlotType": "Weapon"
},
{ …Run Code Online (Sandbox Code Playgroud)