|
|
|
|
|
|
ReloadCallHierarchy(); |
|
|
|
} |
|
|
|
GUILayout.FlexibleSpace(); |
|
|
|
Rect buttonRect = GUILayoutUtility.GetRect(64, 16); |
|
|
|
m_TreeView.stringFilter = EditorGUILayout.DelayedTextField(m_TreeView.stringFilter, EditorStyles.toolbarSearchField); |
|
|
|
|
|
|
|
Rect buttonRect = GUILayoutUtility.GetRect(52, 16); |
|
|
|
if (GUI.Button(buttonRect, "Filter", EditorStyles.toolbarDropDown)) |
|
|
|
{ |
|
|
|
GenericMenu menu = new GenericMenu(); |
|
|
|
|
|
|
menu.AddItem(new GUIContent("Clear Filter"), false, () => { |
|
|
|
m_TreeView.SetAutoFilter(false); |
|
|
|
m_TreeView.SetFilter(null); |
|
|
|
m_TreeView.stringFilter = string.Empty; |
|
|
|
}); |
|
|
|
menu.AddSeparator(""); |
|
|
|
menu.AddItem(new GUIContent("Automatic Filter"), m_TreeView.AutoFilter, () => { |
|
|
|
|
|
|
var listRoot = nodeRoots[name]; |
|
|
|
foreach (var item in list) |
|
|
|
{ |
|
|
|
var stack = new Stack<object>(); |
|
|
|
|
|
|
|
listRoot.Add(GetStateMachineNode(item as StateMachine)); |
|
|
|
listRoot.Add(GetStateMachineNode(item as StateMachine, stack)); |
|
|
|
listRoot.Add(GetMessageNode(item as SendMessageAction)); |
|
|
|
listRoot.Add(GetMessageNode(item as SendMessageAction, stack)); |
|
|
|
listRoot.Add(GetNode(item)); |
|
|
|
listRoot.Add(GetNode(item, stack)); |
|
|
|
CallTreeNode GetNode(MonoBehaviour bhv) |
|
|
|
CallTreeNode GetNode(MonoBehaviour bhv, Stack<object> stack) |
|
|
|
var rootNode = new CallTreeNode(bhv, GetType(bhv), $"{bhv.gameObject.name} ({bhv.GetType().Name})"); |
|
|
|
var type = bhv.GetType(); |
|
|
|
foreach (var field in type.GetFields()) |
|
|
|
if(!stack.Contains(bhv)) |
|
|
|
// Find Fields that are Callable[]
|
|
|
|
if (field.FieldType.IsAssignableFrom(typeof(Callable[]))) |
|
|
|
stack.Push(bhv); |
|
|
|
var rootNode = new CallTreeNode(bhv, GetType(bhv), $"{bhv.gameObject.name} ({bhv.GetType().Name})"); |
|
|
|
var type = bhv.GetType(); |
|
|
|
foreach (var field in type.GetFields()) |
|
|
|
var node = new CallTreeNode(bhv, CallTreeNodeType.Callable, field.Name); |
|
|
|
var value = (Callable[])field.GetValue(bhv); |
|
|
|
// Find Fields that are Callable[]
|
|
|
|
if (field.FieldType.IsAssignableFrom(typeof(Callable[]))) |
|
|
|
{ |
|
|
|
var node = new CallTreeNode(bhv, CallTreeNodeType.Callable, field.Name); |
|
|
|
var value = (Callable[])field.GetValue(bhv); |
|
|
|
if (value != null && value.Length > 0) |
|
|
|
{ |
|
|
|
rootNode.Children.Add(node); |
|
|
|
// Add Callables from this Callable[] array
|
|
|
|
foreach (var call in value) |
|
|
|
if (value != null && value.Length > 0) |
|
|
|
node.Children.Add(GetNode(call)); |
|
|
|
rootNode.Children.Add(node); |
|
|
|
// Add Callables from this Callable[] array
|
|
|
|
foreach (var call in value) |
|
|
|
{ |
|
|
|
node.Children.Add(GetNode(call, stack)); |
|
|
|
} |
|
|
|
return rootNode; |
|
|
|
return rootNode; |
|
|
|
else |
|
|
|
{ |
|
|
|
return new CallTreeNode(bhv, GetType(bhv), $"RECURSED : {bhv.gameObject.name} ({bhv.GetType().Name})"); |
|
|
|
} |
|
|
|
|
|
|
|
CallTreeNode GetMessageNode(SendMessageAction sm) |
|
|
|
CallTreeNode GetMessageNode(SendMessageAction msg, Stack<object> stack) |
|
|
|
var rootNode = new CallTreeNode(sm, CallTreeNodeType.Message, $"{sm.MessageToSend} : ({sm.gameObject.name}.{sm.Name})"); |
|
|
|
var all = Resources.FindObjectsOfTypeAll<OnMessageEvent>().Where(o=> o.MessageName == sm.MessageToSend).ToList(); |
|
|
|
if (!stack.Contains(msg)) |
|
|
|
{ |
|
|
|
stack.Push(msg); |
|
|
|
var rootNode = new CallTreeNode(msg, CallTreeNodeType.Message, $"{msg.MessageToSend} : ({msg.gameObject.name}.{msg.Name})"); |
|
|
|
var all = Resources.FindObjectsOfTypeAll<OnMessageEvent>().Where(o=> o.MessageName == msg.MessageToSend).ToList(); |
|
|
|
foreach(var evt in all) |
|
|
|
foreach(var evt in all) |
|
|
|
{ |
|
|
|
rootNode.Children.Add(GetNode(evt, stack)); |
|
|
|
} |
|
|
|
return rootNode; |
|
|
|
} |
|
|
|
else |
|
|
|
rootNode.Children.Add(GetNode(evt)); |
|
|
|
return new CallTreeNode(msg, GetType(msg), $"RECURSED :{msg.MessageToSend} : ({msg.gameObject.name}.{msg.Name})"); |
|
|
|
return rootNode; |
|
|
|
CallTreeNode GetStateMachineNode(StateMachine sm) |
|
|
|
CallTreeNode GetStateMachineNode(StateMachine sm, Stack<object> stack) |
|
|
|
var rootNode = new CallTreeNode(sm, CallTreeNodeType.StateMachine, sm.gameObject.name); |
|
|
|
var type = sm.GetType(); |
|
|
|
foreach (var field in type.GetFields()) |
|
|
|
if (!stack.Contains(sm)) |
|
|
|
// Find Fields that are State[]
|
|
|
|
if (field.FieldType.IsAssignableFrom(typeof(State[]))) |
|
|
|
stack.Push(sm); |
|
|
|
var rootNode = new CallTreeNode(sm, CallTreeNodeType.StateMachine, sm.gameObject.name); |
|
|
|
var type = sm.GetType(); |
|
|
|
foreach (var field in type.GetFields()) |
|
|
|
// Add Callables from this Callable[] array
|
|
|
|
var value = (State[])field.GetValue(sm); |
|
|
|
foreach (var state in value) |
|
|
|
// Find Fields that are State[]
|
|
|
|
if (field.FieldType.IsAssignableFrom(typeof(State[]))) |
|
|
|
rootNode.Children.Add(GetStateNode(state)); |
|
|
|
// Add Callables from this Callable[] array
|
|
|
|
var value = (State[])field.GetValue(sm); |
|
|
|
foreach (var state in value) |
|
|
|
{ |
|
|
|
rootNode.Children.Add(GetStateNode(state, stack)); |
|
|
|
} |
|
|
|
return rootNode; |
|
|
|
return rootNode; |
|
|
|
else |
|
|
|
{ |
|
|
|
return new CallTreeNode(sm, GetType(sm), $"RECURSED :{sm.gameObject.name}"); |
|
|
|
} |
|
|
|
|
|
|
|
CallTreeNode GetStateNode(State st) |
|
|
|
CallTreeNode GetStateNode(State st, Stack<object> stack) |
|
|
|
var rootNode = new CallTreeNode(st, CallTreeNodeType.State, st.gameObject.name); |
|
|
|
var type = st.GetType(); |
|
|
|
foreach (var field in type.GetFields()) |
|
|
|
if (!stack.Contains(st)) |
|
|
|
// Find Fields that are Callable[]
|
|
|
|
if (field.FieldType.IsAssignableFrom(typeof(Callable[]))) |
|
|
|
stack.Push(st); |
|
|
|
var rootNode = new CallTreeNode(st, CallTreeNodeType.State, st.gameObject.name); |
|
|
|
var type = st.GetType(); |
|
|
|
foreach (var field in type.GetFields()) |
|
|
|
var node = new CallTreeNode(st, CallTreeNodeType.Callable, field.Name); |
|
|
|
rootNode.Children.Add(node); |
|
|
|
// Add Callables from this Callable[] array
|
|
|
|
var value = (Callable[])field.GetValue(st); |
|
|
|
foreach (var call in value) |
|
|
|
// Find Fields that are Callable[]
|
|
|
|
if (field.FieldType.IsAssignableFrom(typeof(Callable[]))) |
|
|
|
node.Children.Add(GetNode(call)); |
|
|
|
var node = new CallTreeNode(st, CallTreeNodeType.Callable, field.Name); |
|
|
|
rootNode.Children.Add(node); |
|
|
|
// Add Callables from this Callable[] array
|
|
|
|
var value = (Callable[])field.GetValue(st); |
|
|
|
foreach (var call in value) |
|
|
|
{ |
|
|
|
node.Children.Add(GetNode(call, stack)); |
|
|
|
} |
|
|
|
return rootNode; |
|
|
|
return rootNode; |
|
|
|
else |
|
|
|
{ |
|
|
|
return new CallTreeNode(st, GetType(st), $"RECURSED :{st.gameObject.name}"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
CallTreeNodeType GetType(MonoBehaviour bhv) |
|
|
|
|
|
|
Children = new List<CallTreeNode>(); |
|
|
|
} |
|
|
|
|
|
|
|
public bool ContainsReference(GameObject go) |
|
|
|
public bool Filter(GameObject go, string filter) |
|
|
|
if (go == null) |
|
|
|
if (go == null && string.IsNullOrEmpty(filter)) |
|
|
|
if (this.Target.gameObject == go) |
|
|
|
if (this.Target.gameObject == go && string.IsNullOrEmpty(filter)? true: this.Name.Contains(filter)) |
|
|
|
value = value || node.ContainsReference(go); |
|
|
|
value = value || node.Filter(go, filter); |
|
|
|
return value; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
m_Bindings = new Dictionary<int, CallTreeNode>(); |
|
|
|
} |
|
|
|
|
|
|
|
public string stringFilter { get { return m_StringFilter; } set { m_StringFilter = value; this.Reload(); } } |
|
|
|
|
|
|
|
string m_StringFilter = ""; |
|
|
|
|
|
|
|
public bool AutoFilter { get; private set; } |
|
|
|
public void ToggleAutoFilter() |
|
|
|
{ |
|
|
|
|
|
|
treeRoot.AddChild(currentRoot); |
|
|
|
foreach (var node in kvp.Value) |
|
|
|
{ |
|
|
|
if (node.ContainsReference(m_filter)) |
|
|
|
if (node.Filter(m_filter, m_StringFilter)) |
|
|
|
{ |
|
|
|
currentRoot.AddChild(GetNode(node, ref id, 1)); |
|
|
|
} |
|
|
|