浏览代码

Finally Working

/main
Thomas ICHÉ 5 年前
当前提交
d260d160
共有 2 个文件被更改,包括 72 次插入24 次删除
  1. 58
      Editor/CallTree/CallTreeWindow.cs
  2. 38
      Icons/Misc/ic-callable.png

58
Editor/CallTree/CallTreeWindow.cs


{
BuildCallTree();
}
if (GUILayout.Button("Filter Selected", EditorStyles.toolbarButton))
{
m_TreeView.SetFilter(Selection.activeGameObject);
}
GUILayout.FlexibleSpace();
}
Rect r = GUILayoutUtility.GetRect(position.width, position.height - tbHeight);

CallTreeNode GetNode(MonoBehaviour bhv)
{
var rootNode = new CallTreeNode(bhv, GetType(bhv), $"{bhv.gameObject.name} : {bhv.GetType().Name}");
var rootNode = new CallTreeNode(bhv, GetType(bhv), $"{bhv.gameObject.name} ({bhv.GetType().Name})");
var type = bhv.GetType();
foreach (var field in type.GetFields())
{

{
if (bhv == null)
return CallTreeNodeType.Callable;
if (bhv is EventBase)
else if (bhv is EventBase)
return CallTreeNodeType.Event;
else if (bhv is LogicBase)
return CallTreeNodeType.Logic;

Type = type;
Children = new List<CallTreeNode>();
}
public bool ContainsReference(GameObject go)
{
if (go == null)
return true;
else
{
if (this.Target.gameObject == go)
return true;
bool value = false;
foreach (var node in Children)
value = value || node.ContainsReference(go);
return value;
}
}
}
public enum CallTreeNodeType

m_Roots = roots;
m_Bindings = new Dictionary<int, CallTreeNode>();
}
GameObject m_filter = null;
public void SetFilter(GameObject filter = null)
{
m_filter = filter;
this.Reload();
}
var treeRoot = new TreeViewItem(id++, -1, "~Root");
var treeRoot = new TreeViewItem(id, -1, "~Root");
treeRoot.AddChild(GetNode(node, ref id, 0));
if (node.ContainsReference(m_filter))
{
treeRoot.AddChild(GetNode(node, ref id, 0));
}
}
if(treeRoot.children == null)
{
treeRoot.AddChild(new TreeViewItem(1, 0, "(No Results)"));
}
return treeRoot;
}

var item = new TreeViewItem(id++, depth, $"{node.Name} ({node.Type})");
item.icon = GetIcon(node.Type);
id++;
var item = new TreeViewItem(id, depth, $"{node.Name}");
item.icon = GetIcon(node.Target, node.Type);
m_Bindings.Add(id, node);
foreach(var child in node.Children)

return item;
}
Texture2D GetIcon(CallTreeNodeType type)
Texture2D GetIcon(MonoBehaviour bhv, CallTreeNodeType type)
if(bhv != null && type != CallTreeNodeType.Callable)
{
var texture = EditorGUIUtility.ObjectContent(bhv, bhv.GetType()).image;
if (texture != null)
return texture as Texture2D;
}
switch(type)
{
default:

38
Icons/Misc/ic-callable.png

之前 之后
宽度: 16  |  高度: 16  |  大小: 2.0 KiB
正在加载...
取消
保存