public static Type GetEditorCurveValueType(GameObject rootGameObject, EditorCurveBinding curveBinding)
 {
     if (rootGameObject != null)
     {
         return(AnimationUtility.GetEditorCurveValueType(rootGameObject, curveBinding));
     }
     return(CurveBindingUtility.GetEditorCurveValueType(curveBinding));
 }
        public static AnimationWindowKeyframe AddKeyframeToCurve(AnimationWindowState state, AnimationWindowCurve curve, AnimationKeyTime time)
        {
            object currentValue            = CurveBindingUtility.GetCurrentValue(state.activeRootGameObject, curve.binding);
            Type   editorCurveValueType    = CurveBindingUtility.GetEditorCurveValueType(state.activeRootGameObject, curve.binding);
            AnimationWindowKeyframe result = AnimationWindowUtility.AddKeyframeToCurve(curve, currentValue, editorCurveValueType, time);

            state.SaveCurve(curve);
            return(result);
        }
Beispiel #3
0
        public static AnimationWindowCurve CreateDefaultCurve(AnimationClip clip, GameObject rootGameObject, EditorCurveBinding binding)
        {
            Type editorCurveValueType  = CurveBindingUtility.GetEditorCurveValueType(rootGameObject, binding);
            AnimationWindowCurve curve = new AnimationWindowCurve(clip, binding, editorCurveValueType);
            object currentValue        = CurveBindingUtility.GetCurrentValue(rootGameObject, binding);

            if (clip.length == 0f)
            {
                AddKeyframeToCurve(curve, currentValue, editorCurveValueType, AnimationKeyTime.Time(0f, clip.frameRate));
                return(curve);
            }
            AddKeyframeToCurve(curve, currentValue, editorCurveValueType, AnimationKeyTime.Time(0f, clip.frameRate));
            AddKeyframeToCurve(curve, currentValue, editorCurveValueType, AnimationKeyTime.Time(clip.length, clip.frameRate));
            return(curve);
        }
Beispiel #4
0
        private void DoValueField(Rect rect, AnimationWindowHierarchyNode node, int row)
        {
            bool flag = false;

            if (!AnimationMode.InAnimationMode())
            {
                return;
            }
            if (node is AnimationWindowHierarchyPropertyNode)
            {
                AnimationWindowCurve[] curves = node.curves;
                if (curves == null || curves.Length == 0)
                {
                    return;
                }
                AnimationWindowCurve animationWindowCurve = curves[0];
                object currentValue         = CurveBindingUtility.GetCurrentValue(this.state.activeRootGameObject, animationWindowCurve.binding);
                Type   editorCurveValueType = CurveBindingUtility.GetEditorCurveValueType(this.state.activeRootGameObject, animationWindowCurve.binding);
                if (currentValue is float)
                {
                    float num      = (float)currentValue;
                    Rect  position = new Rect(rect.xMax - 75f, rect.y, 50f, rect.height);
                    if (Event.current.type == EventType.MouseMove && position.Contains(Event.current.mousePosition))
                    {
                        AnimationWindowHierarchyGUI.s_WasInsideValueRectFrame = Time.frameCount;
                    }
                    EditorGUI.BeginChangeCheck();
                    if (editorCurveValueType == typeof(bool))
                    {
                        num = (float)((!EditorGUI.Toggle(position, num != 0f)) ? 0 : 1);
                    }
                    else
                    {
                        int  controlID = GUIUtility.GetControlID(123456544, FocusType.Keyboard, position);
                        bool flag2     = GUIUtility.keyboardControl == controlID && EditorGUIUtility.editingTextField && Event.current.type == EventType.KeyDown && (Event.current.character == '\n' || Event.current.character == '\u0003');
                        if (EditorGUI.s_RecycledEditor.controlID == controlID && Event.current.type == EventType.MouseDown && position.Contains(Event.current.mousePosition))
                        {
                            GUIUtility.keyboardControl = controlID;
                        }
                        num = EditorGUI.DoFloatField(EditorGUI.s_RecycledEditor, position, new Rect(0f, 0f, 0f, 0f), controlID, num, EditorGUI.kFloatFieldFormatString, this.m_AnimationSelectionTextField, false);
                        if (flag2)
                        {
                            GUI.changed = true;
                            Event.current.Use();
                        }
                    }
                    if (float.IsInfinity(num) || float.IsNaN(num))
                    {
                        num = 0f;
                    }
                    if (EditorGUI.EndChangeCheck())
                    {
                        AnimationWindowKeyframe animationWindowKeyframe = null;
                        foreach (AnimationWindowKeyframe current in animationWindowCurve.m_Keyframes)
                        {
                            if (Mathf.Approximately(current.time, this.state.time.time))
                            {
                                animationWindowKeyframe = current;
                            }
                        }
                        if (animationWindowKeyframe == null)
                        {
                            AnimationWindowUtility.AddKeyframeToCurve(animationWindowCurve, num, editorCurveValueType, this.state.time);
                        }
                        else
                        {
                            animationWindowKeyframe.value = num;
                        }
                        this.state.SaveCurve(animationWindowCurve);
                        flag = true;
                    }
                }
            }
            if (flag)
            {
                this.state.ResampleAnimation();
            }
        }
        private void DoValueField(Rect rect, AnimationWindowHierarchyNode node, int row)
        {
            bool flag = false;

            if (AnimationMode.InAnimationMode())
            {
                EditorGUI.BeginDisabledGroup(this.state.animationIsReadOnly);
                if (node is AnimationWindowHierarchyPropertyNode)
                {
                    List <AnimationWindowCurve> curves = this.state.GetCurves(node, false);
                    if ((curves == null) || (curves.Count == 0))
                    {
                        return;
                    }
                    AnimationWindowCurve curve  = curves[0];
                    object currentValue         = CurveBindingUtility.GetCurrentValue(this.state.activeRootGameObject, curve.binding);
                    Type   editorCurveValueType = CurveBindingUtility.GetEditorCurveValueType(this.state.activeRootGameObject, curve.binding);
                    if (currentValue is float)
                    {
                        float num      = (float)currentValue;
                        Rect  position = new Rect(rect.xMax - 75f, rect.y, 50f, rect.height);
                        if ((Event.current.type == EventType.MouseMove) && position.Contains(Event.current.mousePosition))
                        {
                            s_WasInsideValueRectFrame = Time.frameCount;
                        }
                        EditorGUI.BeginChangeCheck();
                        if (editorCurveValueType == typeof(bool))
                        {
                            num = !EditorGUI.Toggle(position, num != 0f) ? ((float)0) : ((float)1);
                        }
                        else
                        {
                            int  id    = GUIUtility.GetControlID(0x75bcc20, FocusType.Keyboard, position);
                            bool flag2 = (((GUIUtility.keyboardControl == id) && EditorGUIUtility.editingTextField) && (Event.current.type == EventType.KeyDown)) && ((Event.current.character == '\n') || (Event.current.character == '\x0003'));
                            num = EditorGUI.DoFloatField(EditorGUI.s_RecycledEditor, position, new Rect(0f, 0f, 0f, 0f), id, num, EditorGUI.kFloatFieldFormatString, this.m_AnimationSelectionTextField, false);
                            if (flag2)
                            {
                                GUI.changed = true;
                                Event.current.Use();
                            }
                        }
                        if (float.IsInfinity(num) || float.IsNaN(num))
                        {
                            num = 0f;
                        }
                        if (EditorGUI.EndChangeCheck())
                        {
                            AnimationWindowKeyframe keyframe = null;
                            foreach (AnimationWindowKeyframe keyframe2 in curve.m_Keyframes)
                            {
                                if (Mathf.Approximately(keyframe2.time, this.state.time.time))
                                {
                                    keyframe = keyframe2;
                                }
                            }
                            if (keyframe == null)
                            {
                                AnimationWindowUtility.AddKeyframeToCurve(curve, num, editorCurveValueType, this.state.time);
                            }
                            else
                            {
                                keyframe.value = num;
                            }
                            this.state.SaveCurve(curve);
                            flag = true;
                        }
                    }
                }
                EditorGUI.EndDisabledGroup();
                if (flag)
                {
                    this.state.ResampleAnimation();
                }
            }
        }
 public static System.Type GetEditorCurveValueType(GameObject rootGameObject, EditorCurveBinding curveBinding)
 {
   if ((UnityEngine.Object) rootGameObject != (UnityEngine.Object) null)
     return AnimationUtility.GetEditorCurveValueType(rootGameObject, curveBinding);
   return CurveBindingUtility.GetEditorCurveValueType(curveBinding);
 }
Beispiel #7
0
        private void DoValueField(Rect rect, AnimationWindowHierarchyNode node, int row)
        {
            bool flag1 = false;

            if (!AnimationMode.InAnimationMode())
            {
                return;
            }
            EditorGUI.BeginDisabledGroup(this.state.animationIsReadOnly);
            if (node is AnimationWindowHierarchyPropertyNode)
            {
                List <AnimationWindowCurve> curves = this.state.GetCurves(node, false);
                if (curves == null || curves.Count == 0)
                {
                    return;
                }
                AnimationWindowCurve curve       = curves[0];
                object      currentValue         = CurveBindingUtility.GetCurrentValue(this.state.activeRootGameObject, curve.binding);
                System.Type editorCurveValueType = CurveBindingUtility.GetEditorCurveValueType(this.state.activeRootGameObject, curve.binding);
                if (currentValue is float)
                {
                    float num      = (float)currentValue;
                    Rect  position = new Rect(rect.xMax - 75f, rect.y, 50f, rect.height);
                    if (Event.current.type == EventType.MouseMove && position.Contains(Event.current.mousePosition))
                    {
                        AnimationWindowHierarchyGUI.s_WasInsideValueRectFrame = Time.frameCount;
                    }
                    EditorGUI.BeginChangeCheck();
                    float f;
                    if (editorCurveValueType == typeof(bool))
                    {
                        f = !EditorGUI.Toggle(position, (double)num != 0.0) ? 0.0f : 1f;
                    }
                    else
                    {
                        int  controlId = GUIUtility.GetControlID(123456544, FocusType.Keyboard, position);
                        bool flag2     = GUIUtility.keyboardControl == controlId && EditorGUIUtility.editingTextField && Event.current.type == EventType.KeyDown && ((int)Event.current.character == 10 || (int)Event.current.character == 3);
                        f = EditorGUI.DoFloatField(EditorGUI.s_RecycledEditor, position, new Rect(0.0f, 0.0f, 0.0f, 0.0f), controlId, num, EditorGUI.kFloatFieldFormatString, this.m_AnimationSelectionTextField, false);
                        if (flag2)
                        {
                            GUI.changed = true;
                            Event.current.Use();
                        }
                    }
                    if (float.IsInfinity(f) || float.IsNaN(f))
                    {
                        f = 0.0f;
                    }
                    if (EditorGUI.EndChangeCheck())
                    {
                        AnimationWindowKeyframe animationWindowKeyframe = (AnimationWindowKeyframe)null;
                        using (List <AnimationWindowKeyframe> .Enumerator enumerator = curve.m_Keyframes.GetEnumerator())
                        {
                            while (enumerator.MoveNext())
                            {
                                AnimationWindowKeyframe current = enumerator.Current;
                                if (Mathf.Approximately(current.time, this.state.time.time))
                                {
                                    animationWindowKeyframe = current;
                                }
                            }
                        }
                        if (animationWindowKeyframe == null)
                        {
                            AnimationWindowUtility.AddKeyframeToCurve(curve, (object)f, editorCurveValueType, this.state.time);
                        }
                        else
                        {
                            animationWindowKeyframe.value = (object)f;
                        }
                        this.state.SaveCurve(curve);
                        flag1 = true;
                    }
                }
            }
            EditorGUI.EndDisabledGroup();
            if (!flag1)
            {
                return;
            }
            this.state.ResampleAnimation();
        }