|
@@ -18,22 +18,23 @@ public class PlayerDataEditorWindow : EditorWindow
|
|
|
[MenuItem("Tools/PlayerData 编辑器")]
|
|
|
public static void ShowWindow()
|
|
|
{
|
|
|
- GetWindow<PlayerDataEditorWindow>(true,"PlayerData 编辑器");
|
|
|
+ GetWindow<PlayerDataEditorWindow>(true, "PlayerData 编辑器");
|
|
|
}
|
|
|
|
|
|
private void OnEnable()
|
|
|
{
|
|
|
-
|
|
|
LoadPlayerData();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ private string targetFolder = "";
|
|
|
private void OnGUI()
|
|
|
{
|
|
|
GUIStyle headerStyle = new GUIStyle(EditorStyles.boldLabel) { fontSize = 14, padding = new RectOffset(5, 5, 5, 5) };
|
|
|
GUIStyle sectionStyle = new GUIStyle(EditorStyles.helpBox) { margin = new RectOffset(5, 5, 5, 5), padding = new RectOffset(10, 10, 10, 10) };
|
|
|
-
|
|
|
+
|
|
|
scrollPos = EditorGUILayout.BeginScrollView(scrollPos);
|
|
|
-
|
|
|
+
|
|
|
if (playerData == null)
|
|
|
{
|
|
|
EditorGUILayout.HelpBox("未加载 PlayerData!点击下方创建新数据。", MessageType.Warning);
|
|
@@ -41,15 +42,34 @@ public class PlayerDataEditorWindow : EditorWindow
|
|
|
{
|
|
|
playerData = new AccountFileInfo.PlayerData();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
EditorGUILayout.EndScrollView();
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
EditorGUILayout.LabelField("PlayerData 编辑器", headerStyle);
|
|
|
EditorGUILayout.Space();
|
|
|
-
|
|
|
+
|
|
|
EditorGUILayout.BeginVertical(sectionStyle);
|
|
|
+
|
|
|
+ if (Application.isPlaying)
|
|
|
+ {
|
|
|
+ targetFolder = EditorGUILayout.TextField(targetFolder);
|
|
|
+ if (GUILayout.Button("添加事件", GUILayout.Height(30)))
|
|
|
+ {
|
|
|
+ if (int.TryParse(targetFolder, out int eventid))
|
|
|
+ {
|
|
|
+ var eventList = EventSystemManager.Instance.AddEvent(eventid);
|
|
|
+
|
|
|
+ if (eventList != null)
|
|
|
+ {
|
|
|
+ AccountFileInfo.Instance.playerData.eventList.Add(eventList);
|
|
|
+ AccountFileInfo.Instance.SavePlayerData();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
try
|
|
|
{
|
|
|
DrawFields(playerData, playerData.GetType(), "PlayerData.");
|
|
@@ -58,19 +78,22 @@ public class PlayerDataEditorWindow : EditorWindow
|
|
|
{
|
|
|
EditorGUILayout.HelpBox($"绘制字段时出错: {ex.Message}", MessageType.Error);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
EditorGUILayout.EndVertical();
|
|
|
-
|
|
|
+
|
|
|
EditorGUILayout.Space();
|
|
|
EditorGUILayout.BeginHorizontal();
|
|
|
- if (GUILayout.Button("保存 PlayerData", GUILayout.Height(30)))
|
|
|
+ if (!Application.isPlaying)
|
|
|
{
|
|
|
- if (EditorUtility.DisplayDialog("保存确认", $"确定要保存到 {Application.persistentDataPath + DataFilePath}?\n现有文件将被覆盖。", "确定", "取消"))
|
|
|
+ if (GUILayout.Button("保存 PlayerData", GUILayout.Height(30)))
|
|
|
{
|
|
|
- SavePlayerData();
|
|
|
+ if (EditorUtility.DisplayDialog("保存确认", $"确定要保存到 {Application.persistentDataPath + DataFilePath}?\n现有文件将被覆盖。", "确定", "取消"))
|
|
|
+ {
|
|
|
+ SavePlayerData();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (GUILayout.Button("加载 PlayerData", GUILayout.Height(30)))
|
|
|
{
|
|
|
if (EditorUtility.DisplayDialog("加载确认", $"确定要从 {Application.persistentDataPath + DataFilePath} 加载数据?\n当前编辑的数据将被覆盖。", "确定", "取消"))
|
|
@@ -78,9 +101,9 @@ public class PlayerDataEditorWindow : EditorWindow
|
|
|
LoadPlayerData();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
EditorGUILayout.EndHorizontal();
|
|
|
-
|
|
|
+
|
|
|
EditorGUILayout.EndScrollView();
|
|
|
}
|
|
|
|
|
@@ -289,9 +312,9 @@ public class PlayerDataEditorWindow : EditorWindow
|
|
|
{
|
|
|
if (!Application.isPlaying)
|
|
|
{
|
|
|
- if(playerData == null)
|
|
|
+ if (playerData == null)
|
|
|
playerData = new AccountFileInfo.PlayerData();
|
|
|
-
|
|
|
+
|
|
|
try
|
|
|
{
|
|
|
string path = Application.persistentDataPath + DataFilePath;
|
|
@@ -316,7 +339,6 @@ public class PlayerDataEditorWindow : EditorWindow
|
|
|
{
|
|
|
playerData = AccountFileInfo.Instance.playerData;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
#endif
|