Browse Source

增加了数组显示功能,json类显示功能结构重做

master
DESKTOP-B25GA9E\W35 2 years ago
parent
commit
47d580d026
  1. 1
      Assets/DataClass/response.json
  2. 7
      Assets/DataClass/response.json.meta
  3. 52
      Assets/DataGenerateTools/src/JsonGenerate/JsonFileLoaderEditor.cs

1
Assets/DataClass/response.json

File diff suppressed because one or more lines are too long

7
Assets/DataClass/response.json.meta

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: b0d87232d4b27b34da72ac9799f5970b
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

52
Assets/DataGenerateTools/src/JsonGenerate/JsonFileLoaderEditor.cs

@ -4,6 +4,7 @@ using UnityEditor;
using UnityEngine; using UnityEngine;
using LitJson; using LitJson;
using UnityEditor.AnimatedValues; using UnityEditor.AnimatedValues;
using System;
#if UNITY_EDITOR #if UNITY_EDITOR
namespace JXSoft { namespace JXSoft {
@ -11,8 +12,8 @@ namespace JXSoft {
{ {
public TextAsset JsonFile; public TextAsset JsonFile;
AnimBool m_ShowExtraFields; AnimBool m_ShowExtraFields;
private JsonReader reader; private JsonData jsonData;
public Dictionary<string, string> keyValuePairs = new Dictionary<string, string>(); private List<bool> hoverArrowGroup;
[MenuItem("JXSoft/Loader/JsonFileLoader")] [MenuItem("JXSoft/Loader/JsonFileLoader")]
@ -35,29 +36,46 @@ namespace JXSoft {
} }
if (GUILayout.Button("Clear")) { if (GUILayout.Button("Clear")) {
keyValuePairs.Clear(); jsonData.Clear();
} }
if (JsonFile != null) { if (JsonFile != null) {
/* jsonData = JsonMapper.ToObject(JsonFile.text);
reader = new JsonReader(JsonFile.text); loadData(jsonData);
}
while (reader.Read()) }
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() : ""; EditorGUILayout.TextField(key, data[key].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();
} }
*/
} }
} }
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 #endif

Loading…
Cancel
Save