|
|
|
|
|
|
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); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|