|
|
@ -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 |
|
|
|