Browse Source

添加Reader加载到UI使用案例

master
DESKTOP-B25GA9E\W35 2 years ago
parent
commit
d956c96b11
  1. 29
      Assets/DataGenerateTools/src/JsonGenerate/JsonFileLoaderEditor.cs
  2. 8
      Assets/JsonIOTools/src.meta
  3. 0
      Assets/JsonIOTools/src/JsonIOUtility.cs
  4. 0
      Assets/JsonIOTools/src/JsonIOUtility.cs.meta

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

@ -11,7 +11,9 @@ namespace JXSoft { @@ -11,7 +11,9 @@ namespace JXSoft {
{
public TextAsset JsonFile;
AnimBool m_ShowExtraFields;
public Dictionary<string, string> keyValuePairs;
private JsonReader reader;
public Dictionary<string, string> keyValuePairs = new Dictionary<string, string>();
[MenuItem("JXSoft/Loader/JsonFileLoader")]
static void Init()
@ -30,17 +32,24 @@ namespace JXSoft { @@ -30,17 +32,24 @@ namespace JXSoft {
JsonFile = (TextAsset)EditorGUILayout.ObjectField("JsonFile", JsonFile, typeof(TextAsset), true);
if (GUILayout.Button("AnalyzeJsonFile"))
{
if (JsonFile != null)
{
JsonData jsonData = JsonMapper.ToObject(JsonFile.text);
foreach (string key in jsonData.Keys)
{
Debug.Log(jsonData[key].GetJsonType());
for (int i = 0; i < jsonData[key].Count; i++) {
Debug.Log(jsonData[key][i].GetJsonType());
}
}
if (GUILayout.Button("Clear")) {
keyValuePairs.Clear();
}
if (JsonFile != null) {
reader = new JsonReader(JsonFile.text);
/*
while (reader.Read())
{
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();
}*/
}
}
}

8
Assets/JsonIOTools/src.meta

@ -0,0 +1,8 @@ @@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 14a068b61b6865f4ab64901c885086d6
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

0
Assets/JsonIOTools/JsonIOUtility.cs → Assets/JsonIOTools/src/JsonIOUtility.cs

0
Assets/JsonIOTools/JsonIOUtility.cs.meta → Assets/JsonIOTools/src/JsonIOUtility.cs.meta

Loading…
Cancel
Save