Beispiel #1
0
        private static void ResetValues(MenuCommand command)
        {
            AnimationWindowEvent animationWindowEvent = command.context as AnimationWindowEvent;

            AnimationWindowEvent[] awEvents = new AnimationWindowEvent[]
            {
                animationWindowEvent
            };
            AnimationWindowEventInspector.AnimationWindowEventData data = AnimationWindowEventInspector.GetData(awEvents);
            if (data.events != null && data.selectedEvents != null && data.selectedEvents.Length != 0)
            {
                AnimationEvent[] selectedEvents = data.selectedEvents;
                for (int i = 0; i < selectedEvents.Length; i++)
                {
                    AnimationEvent animationEvent = selectedEvents[i];
                    animationEvent.functionName             = "";
                    animationEvent.stringParameter          = string.Empty;
                    animationEvent.floatParameter           = 0f;
                    animationEvent.intParameter             = 0;
                    animationEvent.objectReferenceParameter = null;
                }
                AnimationWindowEventInspector.SetData(awEvents, data);
            }
        }
Beispiel #2
0
 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);
         }
     }
 }