From d956c96b11d52986f4f95cb252ab27ff1ed3ba00 Mon Sep 17 00:00:00 2001 From: "DESKTOP-B25GA9E\\W35" <1733709035@qq.com> Date: Fri, 10 Mar 2023 14:32:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0Reader=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E5=88=B0UI=E4=BD=BF=E7=94=A8=E6=A1=88=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/JsonGenerate/JsonFileLoaderEditor.cs | 31 ++++++++++++------- Assets/JsonIOTools/src.meta | 8 +++++ Assets/JsonIOTools/{ => src}/JsonIOUtility.cs | 0 .../{ => src}/JsonIOUtility.cs.meta | 0 4 files changed, 28 insertions(+), 11 deletions(-) create mode 100644 Assets/JsonIOTools/src.meta rename Assets/JsonIOTools/{ => src}/JsonIOUtility.cs (100%) rename Assets/JsonIOTools/{ => src}/JsonIOUtility.cs.meta (100%) diff --git a/Assets/DataGenerateTools/src/JsonGenerate/JsonFileLoaderEditor.cs b/Assets/DataGenerateTools/src/JsonGenerate/JsonFileLoaderEditor.cs index af264df..5b942e4 100644 --- a/Assets/DataGenerateTools/src/JsonGenerate/JsonFileLoaderEditor.cs +++ b/Assets/DataGenerateTools/src/JsonGenerate/JsonFileLoaderEditor.cs @@ -11,7 +11,9 @@ namespace JXSoft { { public TextAsset JsonFile; AnimBool m_ShowExtraFields; - public Dictionary keyValuePairs; + private JsonReader reader; + public Dictionary keyValuePairs = new Dictionary(); + [MenuItem("JXSoft/Loader/JsonFileLoader")] static void Init() @@ -30,17 +32,24 @@ namespace JXSoft { JsonFile = (TextAsset)EditorGUILayout.ObjectField("JsonFile", JsonFile, typeof(TextAsset), true); if (GUILayout.Button("AnalyzeJsonFile")) { - if (JsonFile != null) + + } + if (GUILayout.Button("Clear")) { + keyValuePairs.Clear(); + } + if (JsonFile != null) { + reader = new JsonReader(JsonFile.text); + /* + while (reader.Read()) { - JsonData jsonData = JsonMapper.ToObject(JsonFile.text); - foreach (string key in jsonData.Keys) - { - Debug.Log(jsonData[key].GetJsonType()); - for (int i = 0; i < jsonData[key].Count; i++) { - Debug.Log(jsonData[key][i].GetJsonType()); - } - } - } + string type = reader.Value != null ? reader.Value.GetType().ToString() : ""; + string value = reader.Value != null ? reader.Value.ToString() : ""; + EditorGUILayout.BeginHorizontal("Label"); + EditorGUILayout.TextField("Type", type); + EditorGUILayout.TextField("Token", reader.Token.ToString()); + EditorGUILayout.TextField("Value", value); + EditorGUILayout.EndHorizontal(); + }*/ } } } diff --git a/Assets/JsonIOTools/src.meta b/Assets/JsonIOTools/src.meta new file mode 100644 index 0000000..5a31cb0 --- /dev/null +++ b/Assets/JsonIOTools/src.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 14a068b61b6865f4ab64901c885086d6 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/JsonIOTools/JsonIOUtility.cs b/Assets/JsonIOTools/src/JsonIOUtility.cs similarity index 100% rename from Assets/JsonIOTools/JsonIOUtility.cs rename to Assets/JsonIOTools/src/JsonIOUtility.cs diff --git a/Assets/JsonIOTools/JsonIOUtility.cs.meta b/Assets/JsonIOTools/src/JsonIOUtility.cs.meta similarity index 100% rename from Assets/JsonIOTools/JsonIOUtility.cs.meta rename to Assets/JsonIOTools/src/JsonIOUtility.cs.meta