Ejemplo n.º 1
0
        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);
                    }
                }
            }
        }