|
|
@@ -6,6 +6,7 @@ using System.Collections.Generic;
|
|
|
using System;
|
|
|
using System.Collections;
|
|
|
using System.IO;
|
|
|
+using Fort23.UTool;
|
|
|
|
|
|
public class PlayerDataEditorWindow : EditorWindow
|
|
|
{
|
|
|
@@ -28,10 +29,15 @@ public class PlayerDataEditorWindow : EditorWindow
|
|
|
|
|
|
|
|
|
private string targetFolder = "";
|
|
|
+ private string targetItemId = "";
|
|
|
+ private string targetItemCount = "";
|
|
|
+
|
|
|
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) };
|
|
|
+ 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);
|
|
|
|
|
|
@@ -60,14 +66,29 @@ public class PlayerDataEditorWindow : EditorWindow
|
|
|
if (int.TryParse(targetFolder, out int eventid))
|
|
|
{
|
|
|
var eventList = EventSystemManager.Instance.AddEvent(eventid);
|
|
|
-
|
|
|
+
|
|
|
if (eventList != null)
|
|
|
{
|
|
|
+ LogTool.Log("添加事件:" + eventid);
|
|
|
AccountFileInfo.Instance.playerData.eventList.Add(eventList);
|
|
|
AccountFileInfo.Instance.SavePlayerData();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ EditorGUILayout.LabelField("道具id:", GUILayout.Width(200));
|
|
|
+ targetItemId = EditorGUILayout.TextField(targetItemId);
|
|
|
+ EditorGUILayout.LabelField("道具数量:", GUILayout.Width(200));
|
|
|
+ targetItemCount = EditorGUILayout.TextField(targetItemCount);
|
|
|
+ if (GUILayout.Button("添加道具", GUILayout.Height(30)))
|
|
|
+ {
|
|
|
+ if (int.TryParse(targetItemId, out int itemId) && int.TryParse(targetItemCount, out int itemCount))
|
|
|
+ {
|
|
|
+ PlayerManager.Instance.BagController.AddItem(itemId, itemCount);
|
|
|
+ LogTool.Log($"添加成功,id:{itemId},数量:{itemCount}");
|
|
|
+ AccountFileInfo.Instance.SavePlayerData();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
try
|
|
|
@@ -87,7 +108,8 @@ public class PlayerDataEditorWindow : EditorWindow
|
|
|
{
|
|
|
if (GUILayout.Button("保存 PlayerData", GUILayout.Height(30)))
|
|
|
{
|
|
|
- if (EditorUtility.DisplayDialog("保存确认", $"确定要保存到 {Application.persistentDataPath + DataFilePath}?\n现有文件将被覆盖。", "确定", "取消"))
|
|
|
+ if (EditorUtility.DisplayDialog("保存确认",
|
|
|
+ $"确定要保存到 {Application.persistentDataPath + DataFilePath}?\n现有文件将被覆盖。", "确定", "取消"))
|
|
|
{
|
|
|
SavePlayerData();
|
|
|
}
|
|
|
@@ -96,7 +118,8 @@ public class PlayerDataEditorWindow : EditorWindow
|
|
|
|
|
|
if (GUILayout.Button("加载 PlayerData", GUILayout.Height(30)))
|
|
|
{
|
|
|
- if (EditorUtility.DisplayDialog("加载确认", $"确定要从 {Application.persistentDataPath + DataFilePath} 加载数据?\n当前编辑的数据将被覆盖。", "确定", "取消"))
|
|
|
+ if (EditorUtility.DisplayDialog("加载确认",
|
|
|
+ $"确定要从 {Application.persistentDataPath + DataFilePath} 加载数据?\n当前编辑的数据将被覆盖。", "确定", "取消"))
|
|
|
{
|
|
|
LoadPlayerData();
|
|
|
}
|
|
|
@@ -173,7 +196,8 @@ public class PlayerDataEditorWindow : EditorWindow
|
|
|
IList list = (IList)(value ?? Activator.CreateInstance(field.FieldType));
|
|
|
|
|
|
EditorGUILayout.BeginHorizontal();
|
|
|
- foldoutStates[fieldKey] = EditorGUILayout.Foldout(foldoutStates[fieldKey], $"{field.Name} (列表, {list.Count} 项)", true);
|
|
|
+ foldoutStates[fieldKey] =
|
|
|
+ EditorGUILayout.Foldout(foldoutStates[fieldKey], $"{field.Name} (列表, {list.Count} 项)", true);
|
|
|
EditorGUILayout.EndHorizontal();
|
|
|
|
|
|
if (foldoutStates[fieldKey])
|
|
|
@@ -209,7 +233,8 @@ public class PlayerDataEditorWindow : EditorWindow
|
|
|
foldoutStates[itemKey] = false;
|
|
|
|
|
|
EditorGUILayout.BeginHorizontal();
|
|
|
- foldoutStates[itemKey] = EditorGUILayout.Foldout(foldoutStates[itemKey], $"{field.Name}[{i}]", true);
|
|
|
+ foldoutStates[itemKey] =
|
|
|
+ EditorGUILayout.Foldout(foldoutStates[itemKey], $"{field.Name}[{i}]", true);
|
|
|
if (GUILayout.Button("删除", GUILayout.Width(60)))
|
|
|
{
|
|
|
list.RemoveAt(i);
|
|
|
@@ -258,7 +283,8 @@ public class PlayerDataEditorWindow : EditorWindow
|
|
|
else if (field.FieldType.IsClass)
|
|
|
{
|
|
|
EditorGUILayout.BeginHorizontal();
|
|
|
- foldoutStates[fieldKey] = EditorGUILayout.Foldout(foldoutStates[fieldKey], $"{field.Name} ({field.FieldType.Name})", true);
|
|
|
+ foldoutStates[fieldKey] = EditorGUILayout.Foldout(foldoutStates[fieldKey],
|
|
|
+ $"{field.Name} ({field.FieldType.Name})", true);
|
|
|
if (value == null && GUILayout.Button("创建", GUILayout.Width(60)))
|
|
|
{
|
|
|
value = Activator.CreateInstance(field.FieldType);
|