Xingwei Zhu
4 年前
当前提交
bffa7eab
共有 7 个文件被更改,包括 175 次插入 和 56 次删除
-
18com.unity.uiwidgets/Runtime/developer/extension.cs
-
11com.unity.uiwidgets/Runtime/foundation/binding.cs
-
13com.unity.uiwidgets/Runtime/foundation/diagnostics.cs
-
6com.unity.uiwidgets/Runtime/widgets/binding.cs
-
106com.unity.uiwidgets/Runtime/widgets/widget_inspector.cs
-
74com.unity.uiwidgets/Editor/testDebugger.cs
-
3com.unity.uiwidgets/Editor/testDebugger.cs.meta
|
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using Unity.UIWidgets.async; |
|||
} |
|||
|
|||
static Dictionary<string, DeveloperExtensionFunc> extensions = new Dictionary<string, DeveloperExtensionFunc>(); |
|||
|
|||
public delegate Future<IDictionary<string, object>> DeveloperExtensionFunc(string method, IDictionary<string, string> parameters); |
|||
|
|||
public static void registerExtension(string methodName, DeveloperExtensionFunc func) { |
|||
extensions[methodName] = func; |
|||
} |
|||
|
|||
public static Future<IDictionary<string, object>> callExtension(string method, |
|||
IDictionary<string, string> parameters) { |
|||
if (extensions.ContainsKey(method)) { |
|||
return extensions[method].Invoke(method, parameters); |
|||
} |
|||
|
|||
return null; |
|||
} |
|||
} |
|||
} |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
using developer; |
|||
using UnityEditor; |
|||
using UnityEngine; |
|||
|
|||
namespace Unity.UIWidgets.Editor { |
|||
public class testDebugger : EditorWindow{ |
|||
[MenuItem("Window/TestInspector")] |
|||
static void Init() { |
|||
var myWindow = (testDebugger) EditorWindow.GetWindow(typeof(testDebugger)); |
|||
myWindow.Show(); |
|||
; } |
|||
|
|||
static void ShowJsonMap(IDictionary<string, object> jsonMap) { |
|||
StringBuilder sb = new StringBuilder(); |
|||
foreach (var key in jsonMap.Keys) { |
|||
if (key == "result" && jsonMap[key] is Dictionary<string ,object>) { |
|||
var resultMap = jsonMap[key] as Dictionary<string, object>; |
|||
foreach (var ckey in resultMap.Keys) { |
|||
sb.Append($"result.{ckey} : {resultMap[ckey] ?? "Null"}\n"); |
|||
} |
|||
} |
|||
sb.Append($"{key} : {jsonMap[key] ?? "Null"}\n"); |
|||
} |
|||
Debug.Log(sb.ToString()); |
|||
} |
|||
|
|||
void OnGUI() { |
|||
if (GUILayout.Button("getRootWidget")) { |
|||
var result = developer_.callExtension("inspector.getRootWidget", new Dictionary<string, string> { |
|||
{"objectGroup", "root"} |
|||
}); |
|||
|
|||
result.then(o => { |
|||
var res = (IDictionary<string, object>) o; |
|||
ShowJsonMap(res); |
|||
}); |
|||
} |
|||
if (GUILayout.Button("getRootRenderObject")) { |
|||
var result = developer_.callExtension("inspector.getRootRenderObject", new Dictionary<string, string> { |
|||
{"objectGroup", "root"} |
|||
}); |
|||
|
|||
result.then(o => { |
|||
var res = (IDictionary<string, object>) o; |
|||
ShowJsonMap(res); |
|||
}); |
|||
} |
|||
if (GUILayout.Button("getRootWidgetSummaryTree")) { |
|||
var result = developer_.callExtension("inspector.getRootWidgetSummaryTree", new Dictionary<string, string> { |
|||
{"objectGroup", "root"} |
|||
}); |
|||
|
|||
result.then(o => { |
|||
var res = (IDictionary<string, object>) o; |
|||
ShowJsonMap(res); |
|||
}); |
|||
} |
|||
if (GUILayout.Button("getChildren")) { |
|||
var result = developer_.callExtension("inspector.getChildren", new Dictionary<string, string> { |
|||
{"objectGroup", "root"}, |
|||
{"arg", "inspector-0"} |
|||
}); |
|||
|
|||
result.then(o => { |
|||
var res = (IDictionary<string, object>) o; |
|||
ShowJsonMap(res); |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 21834a4aede04baa875605d4c82d7bd5 |
|||
timeCreated: 1625239357 |
撰写
预览
正在加载...
取消
保存
Reference in new issue