浏览代码

Added Erroneous Category in Call Tree Window

/main
Thomas ICHÉ 5 年前
当前提交
9ef06df4
共有 2 个文件被更改,包括 45 次插入7 次删除
  1. 4
      CHANGELOG.md
  2. 48
      Editor/CallTree/CallTreeWindow.cs

4
CHANGELOG.md


## 2019.3.1
#### Added
* **Call Tree Explorer**: Added Category for Erroneous Calls
#### Fixed
* Fixed `OnValidate` for FirstPersonController leading to infinite import loop when displaying the inspector for a Prefab Asset.

48
Editor/CallTree/CallTreeWindow.cs


private void OnEnable()
{
nodeRoots = new Dictionary<string, List<CallTreeNode>>();
m_TreeView = new CallTreeView(nodeRoots);
m_TreeView = new CallTreeView(nodeRoots);
titleContent = new GUIContent("Callable Tree Explorer", CallTreeView.Styles.Callable);
ReloadCallHierarchy();
EditorSceneManager.sceneOpened += Reload;

GUILayout.FlexibleSpace();
EditorGUI.BeginChangeCheck();
string filter = EditorGUILayout.DelayedTextField(m_TreeView.stringFilter, EditorStyles.toolbarSearchField);
if(EditorGUI.EndChangeCheck())
if (EditorGUI.EndChangeCheck())
{
m_TreeView.SetStringFilter(filter);
}

}
Dictionary<string, List<CallTreeNode>> nodeRoots;
List<MonoBehaviour> erroneous;
void ReloadCallHierarchy()
{

nodeRoots.Clear();
erroneous = new List<MonoBehaviour>();
CollectErroneousCallables();
void CollectErroneousCallables()
{
if (erroneous == null || erroneous.Count == 0)
return;
var root = new List<CallTreeNode>();
nodeRoots.Add("Erroneous Callables", root);
foreach(var callable in erroneous)
{
root.Add(new CallTreeNode(callable, CallTreeNodeType.Callable, callable.name));
}
}
void AddErroneous(MonoBehaviour bhv)
{
if (!erroneous.Contains(bhv))
erroneous.Add(bhv);
}
void AddToCategory<T>(string name) where T:MonoBehaviour
{
var list = Resources.FindObjectsOfTypeAll<T>().ToList();

foreach (var call in value)
{
if (call != null)
node.Children.Add(GetCallableNode(call, stack));
node.Children.Add(GetCallableNode(call, stack));
else
AddErroneous(node.Target);
}
}
}

// Add Callables from this Callable[] array
foreach (var call in value)
{
node.Children.Add(GetCallableNode(call, stack));
if (call != null)
node.Children.Add(GetCallableNode(call, stack));
else
AddErroneous(node.Target);
}
}
}

var value = (State[])field.GetValue(sm);
foreach (var state in value)
{
rootNode.Children.Add(GetStateNode(state, stack));
if (state != null)
rootNode.Children.Add(GetStateNode(state, stack));
else
AddErroneous(rootNode.Target);
}
}
}

var value = (Callable[])field.GetValue(st);
foreach (var call in value)
{
node.Children.Add(GetNode(call, stack));
if (call != null)
node.Children.Add(GetNode(call, stack));
else
AddErroneous(rootNode.Target);
}
}
}

正在加载...
取消
保存