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 @@ @@ -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; @@ -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 { @@ -11,8 +12,8 @@ namespace JXSoft {
{
public TextAsset JsonFile;
AnimBool m_ShowExtraFields;
private JsonReader reader;
public Dictionary<string, string> keyValuePairs = new Dictionary<string, string>();
private JsonData jsonData;
private List<bool> hoverArrowGroup;
[MenuItem("JXSoft/Loader/JsonFileLoader")]
@ -35,29 +36,46 @@ namespace JXSoft { @@ -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

Loading…
Cancel
Save