|
|
|
@ -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) |
|
|
|
|
{ |
|
|
|
|
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.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 |
|
|
|
|
{ |
|
|
|
|
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 |
|
|
|
|