我有一个单例类,其中包含有关我的游戏的一般信息。
public class GeneralGameData : ScriptableObject
{
private static GeneralGameData _currentGeneralGameData;
public static GeneralGameData CurrentGeneralGameData
{
get
{
if (_currentGeneralGameData == null)
{
_currentGeneralGameData = CreateInstance<GeneralGameData>();
}
DontDestroyOnLoad(_currentGeneralGameData);
return _currentGeneralGameData;
}
}
public string GameName;
public string GameVersion;
}
此类在场景中没有礼物。
我还有一个窗口可以显示和更改它
public class GeneralGameDataMenuItem : EditorWindow
{
[MenuItem("CoreMaker/GeneralGameData")]
private static void _generalGameData()
{
GetWindow<GeneralGameDataMenuItem>("GeneralGameData");
}
void OnGUI()
{
GeneralGameData.CurrentGeneralGameData.GameName = EditorGUILayout.TextField("GameName", GeneralGameData.CurrentGeneralGameData.GameName);
GeneralGameData.CurrentGeneralGameData.GameVersion = EditorGUILayout.TextField("GameVersion", GeneralGameData.CurrentGeneralGameData.GameVersion);
EditorUtility.SetDirty(GeneralGameData.CurrentGeneralGameData);
}
}
问题是在我点击播放或重新启动统一后它不会保存我的更改。有什么解决办法??