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()); + } + } + } } } }