private static string GetEventNameForLogicGraphEvent(IEnumerable <AnimationEvent> events, AnimationEvent animEvent) { for (int i = 1; i < 1000; i++) { string name = "LogicGraphEvent" + i; if (!events.Any((AnimationEvent evt) => AnimationEventPopup.IsLogicGraphEvent(evt) && evt.stringParameter == name)) { string text = "LogicGraphEvent" + i; animEvent.stringParameter = text; return(text); } } return(string.Empty); }
public static string FormatEvent(GameObject root, AnimationEvent evt) { if (string.IsNullOrEmpty(evt.functionName)) { return("(No Function Selected)"); } if (AnimationEventPopup.IsLogicGraphEvent(evt)) { return(AnimationEventPopup.FormatLogicGraphEvent(evt)); } if (!AnimationEventPopup.IsSupportedMethodName(evt.functionName)) { return(evt.functionName + " (Function Not Supported)"); } MonoBehaviour[] components = root.GetComponents <MonoBehaviour>(); for (int i = 0; i < components.Length; i++) { MonoBehaviour monoBehaviour = components[i]; if (!(monoBehaviour == null)) { Type type = monoBehaviour.GetType(); if (type != typeof(MonoBehaviour) && (type.BaseType == null || !(type.BaseType.Name == "GraphBehaviour"))) { MethodInfo method = type.GetMethod(evt.functionName, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method != null) { IEnumerable <Type> paramTypes = from p in method.GetParameters() select p.ParameterType; return(evt.functionName + AnimationEventPopup.FormatEventArguments(paramTypes, evt)); } } } } return(evt.functionName + " (Function Not Supported)"); }
public void OnGUI() { AnimationEvent[] array = null; if (this.m_Clip != null) { array = AnimationUtility.GetAnimationEvents(this.m_Clip); } else { if (this.m_ClipInfo != null) { array = this.m_ClipInfo.GetEvents(); } } if (array == null || this.eventIndex < 0 || this.eventIndex >= array.Length) { return; } GUI.changed = false; AnimationEvent animationEvent = array[this.eventIndex]; if (this.m_Root) { List <string> list; List <Type> list2; AnimationEventPopup.CollectSupportedMethods(this.m_Root, out list, out list2); List <string> list3 = new List <string>(list.Count); for (int i = 0; i < list.Count; i++) { string str = " ( )"; if (list2[i] != null) { if (list2[i] == typeof(float)) { str = " ( float )"; } else { if (list2[i] == typeof(int)) { str = " ( int )"; } else { str = string.Format(" ( {0} )", list2[i].Name); } } } list3.Add(list[i] + str); } int count = list.Count; int num = list.IndexOf(animationEvent.functionName); if (num == -1) { num = list.Count; list.Add(animationEvent.functionName); if (string.IsNullOrEmpty(animationEvent.functionName)) { list3.Add("(No Function Selected)"); } else { list3.Add(animationEvent.functionName + " (Function Not Supported)"); } list2.Add(null); } EditorGUIUtility.labelWidth = 130f; int num2 = num; num = EditorGUILayout.Popup("Function: ", num, list3.ToArray(), new GUILayoutOption[0]); if (num2 != num && num != -1 && num != count) { animationEvent.functionName = list[num]; animationEvent.stringParameter = ((!AnimationEventPopup.IsLogicGraphEvent(animationEvent)) ? string.Empty : AnimationEventPopup.GetEventNameForLogicGraphEvent(array, animationEvent)); } Type type = list2[num]; if (type != null) { EditorGUILayout.Space(); if (type == typeof(AnimationEvent)) { EditorGUILayout.PrefixLabel("Event Data"); } else { EditorGUILayout.PrefixLabel("Parameters"); } if (AnimationEventPopup.IsLogicGraphEvent(animationEvent)) { this.DoEditLogicGraphEventParameters(animationEvent); } else { AnimationEventPopup.DoEditRegularParameters(animationEvent, type); } } } else { animationEvent.functionName = EditorGUILayout.TextField(new GUIContent("Function"), animationEvent.functionName, new GUILayoutOption[0]); AnimationEventPopup.DoEditRegularParameters(animationEvent, typeof(AnimationEvent)); } if (GUI.changed) { if (this.m_Clip != null) { Undo.RegisterCompleteObjectUndo(this.m_Clip, "Animation Event Change"); AnimationUtility.SetAnimationEvents(this.m_Clip, array); } else { if (this.m_ClipInfo != null) { this.m_ClipInfo.SetEvent(this.m_EventIndex, animationEvent); } } } }