protected override AdvancedDropdownItem BuildRoot() { var root = new MethodDropdownItem("Components"); root.AddChild(new MethodDropdownItem("No Function")); SetTargetGameObject(); if (_targetGameObject) { foreach (Component component in _components) { MethodDropdownItem componentItem = new MethodDropdownItem(component.GetType().Name); SetMethodsForObject(component, componentItem); root.AddChild(componentItem); } } return(root); }
private void SetMethodsForObject(Object target, MethodDropdownItem parentItem) { MethodInfo[] methods = target.GetType().GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly).Where(m => !m.IsSpecialName).ToArray(); foreach (MethodInfo method in methods) { string name = method.Name + "("; ParameterInfo[] parameters = method.GetParameters(); for (int i = 0; i < parameters.Length; i++) { name += parameters[i].ParameterType.Name; if (i < parameters.Length - 1) { name += ", "; } } name += ")"; parentItem.AddChild(new MethodDropdownItem(name, new DelegateInfo(target, method))); } }