【发布时间】:2020-01-04 03:53:25
【问题描述】:
我在保存游戏会话时遇到问题。这是保存数据中的一些 JSON 片段。
"boughtSpells":[{"instanceID":13864},{"instanceID":13421}]
这里有一些代码。
[CreateAssetMenu(fileName = "New Spell Pattern", menuName = "SpellPattern")]
[System.Serializable]
public class SpellPattern : ScriptableObject {
public string spellName;
[TextArea]
public string spellDescription;
}
游戏数据模型。
[Serializable]
public class GameData
{
public List<SpellPattern> boughtSpells;
}
我认为它保存了 Unity 的 Scriptable Object ID 的引用(它是唯一的,但不是持久的),而不是序列化其中的数据。 我需要正确序列化数据,但我不知道如何使用 Unity 的 Scriptable Objects 来制作它,但同时我不想更改这些 Scriptable Objects 的架构。
【问题讨论】:
标签: c# unity3d serialization