From 9b996a682827e9819a1f873b850e102b4f14d9a5 Mon Sep 17 00:00:00 2001 From: "DESKTOP-B25GA9E\\W35" <1733709035@qq.com> Date: Thu, 9 Mar 2023 17:54:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E6=96=BD=E4=BA=86=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E7=AE=80=E5=8D=95=E8=AF=BB=E5=8F=96=E4=B8=80=E5=B1=82Json?= =?UTF-8?q?=E7=9A=84=E4=BE=8B=E5=AD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/JsonGenerate/GenerateToolsEditor.cs | 29 +++++++++++++++++++ .../JsonGenerate/GenerateToolsEditor.cs.meta | 11 +++++++ .../src/JsonGenerate/JsonFileLoaderEditor.cs | 18 ++++++++---- 3 files changed, 53 insertions(+), 5 deletions(-) create mode 100644 Assets/DataGenerateTools/src/JsonGenerate/GenerateToolsEditor.cs create mode 100644 Assets/DataGenerateTools/src/JsonGenerate/GenerateToolsEditor.cs.meta diff --git a/Assets/DataGenerateTools/src/JsonGenerate/GenerateToolsEditor.cs b/Assets/DataGenerateTools/src/JsonGenerate/GenerateToolsEditor.cs new file mode 100644 index 0000000..60f32a1 --- /dev/null +++ b/Assets/DataGenerateTools/src/JsonGenerate/GenerateToolsEditor.cs @@ -0,0 +1,29 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; + +namespace JXSoft { + + public class GenerateToolsEditor : EditorWindow + { + public TextAsset JsonFile; + + [MenuItem("JXSoft/Generate/JsonStruct")] + static void Init() + { + var window = GetWindow(); + window.Show(); + } + + void OnGUI() + { + JsonFile = (TextAsset)EditorGUILayout.ObjectField("JsonFile", JsonFile, typeof(TextAsset), true); + if (GUILayout.Button("AnalyzeJsonFile")) + { + + } + } + } + +} diff --git a/Assets/DataGenerateTools/src/JsonGenerate/GenerateToolsEditor.cs.meta b/Assets/DataGenerateTools/src/JsonGenerate/GenerateToolsEditor.cs.meta new file mode 100644 index 0000000..e8e303a --- /dev/null +++ b/Assets/DataGenerateTools/src/JsonGenerate/GenerateToolsEditor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 333d97406b2769141b1fb4d484e2d422 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/DataGenerateTools/src/JsonGenerate/JsonFileLoaderEditor.cs b/Assets/DataGenerateTools/src/JsonGenerate/JsonFileLoaderEditor.cs index 23ad37d..af264df 100644 --- a/Assets/DataGenerateTools/src/JsonGenerate/JsonFileLoaderEditor.cs +++ b/Assets/DataGenerateTools/src/JsonGenerate/JsonFileLoaderEditor.cs @@ -11,11 +11,9 @@ namespace JXSoft { { public TextAsset JsonFile; AnimBool m_ShowExtraFields; - string m_String; - Color m_Color = Color.white; - int m_Number = 0; + public Dictionary keyValuePairs; - [MenuItem("JXSoft/Generate/JsonFileLoader")] + [MenuItem("JXSoft/Loader/JsonFileLoader")] static void Init() { var window = GetWindow(); @@ -32,7 +30,17 @@ namespace JXSoft { JsonFile = (TextAsset)EditorGUILayout.ObjectField("JsonFile", JsonFile, typeof(TextAsset), true); if (GUILayout.Button("AnalyzeJsonFile")) { - + if (JsonFile != null) + { + 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()); + } + } + } } } }