From 47d580d026d320ba2355b812b84c44b950f057cb Mon Sep 17 00:00:00 2001 From: "DESKTOP-B25GA9E\\W35" <1733709035@qq.com> Date: Thu, 16 Mar 2023 18:03:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E6=95=B0=E7=BB=84?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E5=8A=9F=E8=83=BD=EF=BC=8Cjson=E7=B1=BB?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E5=8A=9F=E8=83=BD=E7=BB=93=E6=9E=84=E9=87=8D?= =?UTF-8?q?=E5=81=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/DataClass/response.json | 1 + Assets/DataClass/response.json.meta | 7 +++ .../src/JsonGenerate/JsonFileLoaderEditor.cs | 52 +++++++++++++------ 3 files changed, 43 insertions(+), 17 deletions(-) create mode 100644 Assets/DataClass/response.json create mode 100644 Assets/DataClass/response.json.meta diff --git a/Assets/DataClass/response.json b/Assets/DataClass/response.json new file mode 100644 index 0000000..878c45d --- /dev/null +++ b/Assets/DataClass/response.json @@ -0,0 +1 @@ +{"v":1,"mid":1,"time":13,"ip":"192.168.1.253","mac":"A8032ADE2FF8","devices":[[0,"66A4435F0743",-65,"02011A020A080CFF4C001007261B3B1E4CBB18"],[0,"F12233093DA1",-90,"0201061BFFA801B61E0000000000000000000000A13D093322F10000000000"],[0,"75E6D83E8D69",-85,"02010217FF8F032D1134617936101D4122152608085701030483000303AAFD"],[0,"5A29D779391A",-54,"02011A020A080AFF4C0010053918600710"],[0,"798651656C63",-49,"02011A020A070BFF4C001006201ADFAFC54A"],[0,"FCE8007B490E",-58,"02010607FFFCE8067BBD46030300240C094544494649455220424C45"],[3,"246E9F34F316",-49,"1EFF0600010920024B8725E8054AFC72A1064144E8507E3086B1EBD0575CE5"],[0,"C000000159E5",-90,"0201041AFF44594459C000000159E5010901000026FFFFFFFFFFFFFF00FF"],[0,"AC93C4C5F0A6",-70,"02010606096D6964656112FFA806013730303030363946423030333133"],[0,"5133E7C3906B",-56,"0201060AFF4C001005481C6D6A29"],[0,"75E6D83E8D69",-74,"02010217FF8F032D1134617936101D4122152608085701030483000303AAFD"],[3,"246E9F34F316",-52,"1EFF0600010920024B8725E8054AFC72A1064144E8507E3086B1EBD0575CE5"],[0,"4BA79E47789D",-68,"02011A020A070CFF4C0010076F1F30EE6D2F58"],[0,"FCE8007B490E",-63,"02010607FFFCE8067BBD46030300240C094544494649455220424C45"],[0,"AC93C4C5F0A6",-89,"02010606096D6964656112FFA806013730303030363946423030333133"],[0,"807ABF16EB9E",-64,"020105030300CB0E0948544320425320394543313738"],[0,"C20706053C07",-68,"0201061BFF570102FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF03C20706053C07"],[3,"246E9F34F316",-54,"1EFF0600010920024B8725E8054AFC72A1064144E8507E3086B1EBD0575CE5"],[0,"66A4435F0743",-68,"02011A020A080CFF4C001007261B3B1E4CBB18"],[0,"75E6D83E8D69",-84,"02010217FF8F032D1134617936101D4122152608085701030483000303AAFD"],[0,"F12233093DA1",-91,"0201061BFFA801B61E0000000000000000000000A13D093322F10000000000"],[0,"5133E7C3906B",-63,"0201060AFF4C001005481C6D6A29"],[0,"798651656C63",-48,"02011A020A070BFF4C001006201ADFAFC54A"],[0,"5A29D779391A",-57,"02011A020A080AFF4C0010053918600710"],[0,"F12233093DA1",-90,"0201061BFFA801B61E0000000000000000000000A13D093322F10000000000"],[0,"807ABF16EB9E",-59,"020105030300CB0E0948544320425320394543313738"],[0,"F12233093DA1",-91,"0201061BFFA801B61E0000000000000000000000A13D093322F10000000000"],[0,"AC93C4C5F0A6",-78,"02010606096D6964656112FFA806013730303030363946423030333133"],[3,"246E9F34F316",-49,"1EFF0600010920024B8725E8054AFC72A1064144E8507E3086B1EBD0575CE5"],[0,"FCE8007B490E",-60,"02010607FFFCE8067BBD46030300240C094544494649455220424C45"],[0,"75E6D83E8D69",-75,"02010217FF8F032D1134617936101D4122152608085701030483000303AAFD"],[0,"54BF07D15CD3",-69,"02011A020A070BFF4C001006361E0B1A6B11"],[0,"807ABF16EB9E",-59,"020105030300CB0E0948544320425320394543313738"],[0,"4BA79E47789D",-59,"02011A020A070CFF4C0010076F1F30EE6D2F58"],[0,"AC93C4C5F0A6",-89,"02010606096D6964656112FFA806013730303030363946423030333133"],[3,"246E9F34F316",-53,"1EFF0600010920024B8725E8054AFC72A1064144E8507E3086B1EBD0575CE5"],[0,"5133E7C3906B",-64,"0201060AFF4C001005481C6D6A29"],[0,"6C572C9C499D",-88,"02011A020A080BFF4C0010063E1E1308ACB3"],[0,"75E6D83E8D69",-69,"02010217FF8F032D1134617936101D4122152608085701030483000303AAFD"],[0,"66A4435F0743",-67,"02011A020A080CFF4C001007261B3B1E4CBB18"],[0,"807ABF16EB9E",-63,"020105030300CB0E0948544320425320394543313738"],[0,"FCE8007B490E",-63,"02010607FFFCE8067BBD46030300240C094544494649455220424C45"],[3,"246E9F34F316",-53,"1EFF0600010920024B8725E8054AFC72A1064144E8507E3086B1EBD0575CE5"],[0,"5A29D779391A",-56,"02011A020A080AFF4C0010053918600710"],[0,"75E6D83E8D69",-86,"02010217FF8F032D1134617936101D4122152608085701030483000303AAFD"],[0,"F12233093DA1",-89,"0201061BFFA801B61E0000000000000000000000A13D093322F10000000000"],[0,"5133E7C3906B",-57,"0201060AFF4C001005481C6D6A29"],[3,"F4E95F876E54",-91,"07FF4C0012020003"],[0,"54BF07D15CD3",-68,"02011A020A070BFF4C001006361E0B1A6B11"],[3,"246E9F34F316",-58,"1EFF0600010920024B8725E8054AFC72A1064144E8507E3086B1EBD0575CE5"],[0,"535708030130",-57,"0201061AFF4C000215526164696F6C616E642D540900000000FFFF0DFC00"],[0,"AC93C4C5F0A6",-69,"02010606096D6964656112FFA806013730303030363946423030333133"],[0,"4BA79E47789D",-59,"02011A020A070CFF4C0010076F1F30EE6D2F58"],[0,"807ABF16EB9E",-59,"020105030300CB0E0948544320425320394543313738"],[0,"75E6D83E8D69",-74,"02010217FF8F032D1134617936101D4122152608085701030483000303AAFD"],[3,"246E9F34F316",-55,"1EFF0600010920024B8725E8054AFC72A1064144E8507E3086B1EBD0575CE5"],[0,"66A4435F0743",-68,"02011A020A080CFF4C001007261B3B1E4CBB18"],[3,"79B8E2F1EAA2",-78,"1EFF0600010920022DEEB4B0822E85D1CEFD08A2C971AC9FBE2D9F90F93FD0"],[0,"807ABF16EB9E",-63,"020105030300CB0E0948544320425320394543313738"],[0,"AC93C4C5F0A6",-86,"02010606096D6964656112FFA806013730303030363946423030333133"],[0,"5133E7C3906B",-64,"0201060AFF4C001005481C6D6A29"],[0,"798651656C63",-63,"02011A020A070BFF4C001006201ADFAFC54A"],[0,"5A29D779391A",-63,"02011A020A080AFF4C0010053918600710"],[0,"75E6D83E8D69",-85,"02010217FF8F032D1134617936101D4122152608085701030483000303AAFD"],[0,"FCE8007B490E",-57,"02010607FFFCE8067BBD46030300240C094544494649455220424C45"],[3,"53CA41E81332",-79,"1EFF060001092002DFF4079F429653F3ADA291E808F68411C639EEBAD92732"],[3,"246E9F34F316",-53,"1EFF0600010920024B8725E8054AFC72A1064144E8507E3086B1EBD0575CE5"],[0,"807ABF16EB9E",-59,"020105030300CB0E0948544320425320394543313738"],[0,"54BF07D15CD3",-80,"02011A020A070BFF4C001006361E0B1A6B11"],[0,"AC93C4C5F0A6",-70,"02010606096D6964656112FFA806013730303030363946423030333133"],[0,"75E6D83E8D69",-74,"02010217FF8F032D1134617936101D4122152608085701030483000303AAFD"],[0,"4BA79E47789D",-59,"02011A020A070CFF4C0010076F1F30EE6D2F58"],[3,"DAAFAC29C92B",-75,"07FF4C0012020003"],[0,"5133E7C3906B",-57,"0201060AFF4C001005481C6D6A29"],[0,"807ABF16EB9E",-59,"020105030300CB0E0948544320425320394543313738"],[0,"6C572C9C499D",-90,"02011A020A080BFF4C0010063E1E1308ACB3"],[0,"66A4435F0743",-67,"02011A020A080CFF4C001007261B3B1E4CBB18"],[0,"AC93C4C5F0A6",-88,"02010606096D6964656112FFA806013730303030363946423030333133"],[3,"246E9F34F316",-56,"1EFF0600010920024B8725E8054AFC72A1064144E8507E3086B1EBD0575CE5"],[0,"75E6D83E8D69",-69,"02010217FF8F032D1134617936101D4122152608085701030483000303AAFD"],[0,"798651656C63",-65,"02011A020A070BFF4C001006201ADFAFC54A"],[0,"5A29D779391A",-62,"02011A020A080AFF4C0010053918600710"],[0,"807ABF16EB9E",-63,"020105030300CB0E0948544320425320394543313738"],[3,"E61E1B0375F8",-63,"07FF4C0012020002"],[0,"C20706053C07",-61,"0201061BFF570102FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF03C20706053C07"],[3,"246E9F34F316",-52,"1EFF0600010920024B8725E8054AFC72A1064144E8507E3086B1EBD0575CE5"],[0,"5133E7C3906B",-62,"0201060AFF4C001005481C6D6A29"],[0,"AC93C4C5F0A6",-76,"02010606096D6964656112FFA806013730303030363946423030333133"],[0,"54BF07D15CD3",-81,"02011A020A070BFF4C001006361E0B1A6B11"],[0,"F12233093DA1",-90,"0201061BFFA801B61E0000000000000000000000A13D093322F10000000000"]]} \ No newline at end of file diff --git a/Assets/DataClass/response.json.meta b/Assets/DataClass/response.json.meta new file mode 100644 index 0000000..4558f07 --- /dev/null +++ b/Assets/DataClass/response.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: b0d87232d4b27b34da72ac9799f5970b +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/DataGenerateTools/src/JsonGenerate/JsonFileLoaderEditor.cs b/Assets/DataGenerateTools/src/JsonGenerate/JsonFileLoaderEditor.cs index 695956f..0c8190d 100644 --- a/Assets/DataGenerateTools/src/JsonGenerate/JsonFileLoaderEditor.cs +++ b/Assets/DataGenerateTools/src/JsonGenerate/JsonFileLoaderEditor.cs @@ -4,6 +4,7 @@ using UnityEditor; using UnityEngine; using LitJson; using UnityEditor.AnimatedValues; +using System; #if UNITY_EDITOR namespace JXSoft { @@ -11,8 +12,8 @@ namespace JXSoft { { public TextAsset JsonFile; AnimBool m_ShowExtraFields; - private JsonReader reader; - public Dictionary keyValuePairs = new Dictionary(); + private JsonData jsonData; + private List hoverArrowGroup; [MenuItem("JXSoft/Loader/JsonFileLoader")] @@ -35,29 +36,46 @@ namespace JXSoft { } if (GUILayout.Button("Clear")) { - keyValuePairs.Clear(); + jsonData.Clear(); } if (JsonFile != null) { - /* - reader = new JsonReader(JsonFile.text); - - while (reader.Read()) + jsonData = JsonMapper.ToObject(JsonFile.text); + loadData(jsonData); + } + } + public void loadData(JsonData data) { + foreach (string key in data.Keys) + { + if (data[key].IsObject) + { + EditorGUILayout.LabelField(key, EditorStyles.boldLabel); + EditorGUILayout.BeginVertical("Label"); + loadData(data[key]); + EditorGUILayout.EndVertical(); + }else if (data[key].IsArray) { + EditorGUILayout.LabelField(key, EditorStyles.boldLabel); + loadArray(data[key]); + } + else { - 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(); + EditorGUILayout.TextField(key, data[key].ToString()); } - */ } } - public void loadDataFromJson() { - + public void loadArray(JsonData data) { + if (data.IsArray) + { + foreach (JsonData v in data) + { + EditorGUILayout.TextField(v.GetType().ToString(), v.ToString()); + if (v.IsArray) { + loadArray(v); + } + } + } } } + } #endif