public static void OnDisabledAnimationEvent() { AnimationEvent animationEvent = new AnimationEvent(); using (new EditorGUI.DisabledScope(true)) { animationEvent.functionName = EditorGUILayout.TextField(new GUIContent("Function"), animationEvent.functionName, new GUILayoutOption[0]); AnimationWindowEventInspector.DoEditRegularParameters(animationEvent, typeof(AnimationEvent)); } }
public static void OnEditAnimationEvents(AnimationWindowEvent[] awEvents) { AnimationWindowEventInspector.AnimationWindowEventData data = AnimationWindowEventInspector.GetData(awEvents); if (data.events != null && data.selectedEvents != null && data.selectedEvents.Length != 0) { AnimationEvent firstEvent = data.selectedEvents[0]; bool flag = Array.TrueForAll <AnimationEvent>(data.selectedEvents, (AnimationEvent evt) => evt.functionName == firstEvent.functionName); GUI.changed = false; if (data.root != null) { List <AnimationWindowEventMethod> list = AnimationWindowEventInspector.CollectSupportedMethods(data.root); List <string> list2 = new List <string>(list.Count); for (int i = 0; i < list.Count; i++) { AnimationWindowEventMethod animationWindowEventMethod = list[i]; string str = " ( )"; if (animationWindowEventMethod.parameterType != null) { if (animationWindowEventMethod.parameterType == typeof(float)) { str = " ( float )"; } else if (animationWindowEventMethod.parameterType == typeof(int)) { str = " ( int )"; } else { str = string.Format(" ( {0} )", animationWindowEventMethod.parameterType.Name); } } list2.Add(animationWindowEventMethod.name + str); } int count = list.Count; int num = list.FindIndex((AnimationWindowEventMethod method) => method.name == firstEvent.functionName); if (num == -1) { num = list.Count; list.Add(new AnimationWindowEventMethod { name = firstEvent.functionName, parameterType = null }); if (string.IsNullOrEmpty(firstEvent.functionName)) { list2.Add("(No Function Selected)"); } else { list2.Add(firstEvent.functionName + " (Function Not Supported)"); } } EditorGUIUtility.labelWidth = 130f; EditorGUI.showMixedValue = !flag; int num2 = (!flag) ? -1 : num; num = EditorGUILayout.Popup("Function: ", num, list2.ToArray(), new GUILayoutOption[0]); if (num2 != num && num != -1 && num != count) { AnimationEvent[] selectedEvents = data.selectedEvents; for (int j = 0; j < selectedEvents.Length; j++) { AnimationEvent animationEvent = selectedEvents[j]; animationEvent.functionName = list[num].name; animationEvent.stringParameter = string.Empty; } } EditorGUI.showMixedValue = false; Type parameterType = list[num].parameterType; if (flag && parameterType != null) { EditorGUILayout.Space(); if (parameterType == typeof(AnimationEvent)) { EditorGUILayout.PrefixLabel("Event Data"); } else { EditorGUILayout.PrefixLabel("Parameters"); } AnimationWindowEventInspector.DoEditRegularParameters(data.selectedEvents, parameterType); } } else { EditorGUI.showMixedValue = !flag; string text = (!flag) ? "" : firstEvent.functionName; string text2 = EditorGUILayout.TextField(EditorGUIUtility.TrTextContent("Function", null, null), text, new GUILayoutOption[0]); if (text2 != text) { AnimationEvent[] selectedEvents2 = data.selectedEvents; for (int k = 0; k < selectedEvents2.Length; k++) { AnimationEvent animationEvent2 = selectedEvents2[k]; animationEvent2.functionName = text2; animationEvent2.stringParameter = string.Empty; } } EditorGUI.showMixedValue = false; if (flag) { AnimationWindowEventInspector.DoEditRegularParameters(data.selectedEvents, typeof(AnimationEvent)); } else { using (new EditorGUI.DisabledScope(true)) { AnimationEvent animationEvent3 = new AnimationEvent(); AnimationWindowEventInspector.DoEditRegularParameters(new AnimationEvent[] { animationEvent3 }, typeof(AnimationEvent)); } } } if (GUI.changed) { AnimationWindowEventInspector.SetData(awEvents, data); } } }
public static void OnEditAnimationEvent(AnimationWindowEvent awevt) { AnimationEvent[] array = null; if (awevt.clip != null) { array = AnimationUtility.GetAnimationEvents(awevt.clip); } else if (awevt.clipInfo != null) { array = awevt.clipInfo.GetEvents(); } if (array != null && awevt.eventIndex >= 0 && awevt.eventIndex < array.Length) { AnimationEvent evt = array[awevt.eventIndex]; GUI.changed = false; if (awevt.root != null) { List <AnimationWindowEventMethod> list = AnimationWindowEventInspector.CollectSupportedMethods(awevt); List <string> list2 = new List <string>(list.Count); for (int i = 0; i < list.Count; i++) { AnimationWindowEventMethod animationWindowEventMethod = list[i]; string str = " ( )"; if (animationWindowEventMethod.parameterType != null) { if (animationWindowEventMethod.parameterType == typeof(float)) { str = " ( float )"; } else if (animationWindowEventMethod.parameterType == typeof(int)) { str = " ( int )"; } else { str = string.Format(" ( {0} )", animationWindowEventMethod.parameterType.Name); } } list2.Add(animationWindowEventMethod.name + str); } int count = list.Count; int num = list.FindIndex((AnimationWindowEventMethod method) => method.name == evt.functionName); if (num == -1) { num = list.Count; list.Add(new AnimationWindowEventMethod { name = evt.functionName, parameterType = null }); if (string.IsNullOrEmpty(evt.functionName)) { list2.Add("(No Function Selected)"); } else { list2.Add(evt.functionName + " (Function Not Supported)"); } } EditorGUIUtility.labelWidth = 130f; int num2 = num; num = EditorGUILayout.Popup("Function: ", num, list2.ToArray(), new GUILayoutOption[0]); if (num2 != num && num != -1 && num != count) { evt.functionName = list[num].name; evt.stringParameter = string.Empty; } Type parameterType = list[num].parameterType; if (parameterType != null) { EditorGUILayout.Space(); if (parameterType == typeof(AnimationEvent)) { EditorGUILayout.PrefixLabel("Event Data"); } else { EditorGUILayout.PrefixLabel("Parameters"); } AnimationWindowEventInspector.DoEditRegularParameters(evt, parameterType); } } else { evt.functionName = EditorGUILayout.TextField(new GUIContent("Function"), evt.functionName, new GUILayoutOption[0]); AnimationWindowEventInspector.DoEditRegularParameters(evt, typeof(AnimationEvent)); } if (GUI.changed) { if (awevt.clip != null) { Undo.RegisterCompleteObjectUndo(awevt.clip, "Animation Event Change"); AnimationUtility.SetAnimationEvents(awevt.clip, array); } else if (awevt.clipInfo != null) { awevt.clipInfo.SetEvent(awevt.eventIndex, evt); } } } }