private static void AddKey(IAnimationRecordingState state, EditorCurveBinding binding, Type type, PropertyModification modification)
        {
            GameObject    activeRootGameObject = state.activeRootGameObject;
            AnimationClip activeAnimationClip  = state.activeAnimationClip;

            if ((activeAnimationClip.hideFlags & HideFlags.NotEditable) != HideFlags.None)
            {
                return;
            }
            AnimationWindowCurve animationWindowCurve = new AnimationWindowCurve(activeAnimationClip, binding, type);
            object currentValue = CurveBindingUtility.GetCurrentValue(activeRootGameObject, binding);

            if (animationWindowCurve.length == 0)
            {
                object value = null;
                if (!AnimationRecording.ValueFromPropertyModification(modification, binding, out value))
                {
                    value = currentValue;
                }
                if (state.frame != 0)
                {
                    AnimationWindowUtility.AddKeyframeToCurve(animationWindowCurve, value, type, AnimationKeyTime.Frame(0, activeAnimationClip.frameRate));
                }
            }
            AnimationWindowUtility.AddKeyframeToCurve(animationWindowCurve, currentValue, type, AnimationKeyTime.Frame(state.frame, activeAnimationClip.frameRate));
            state.SaveCurve(animationWindowCurve);
        }
Exemple #2
0
        private static GameObject CreateOrGetGameObject(string path)
        {
            if (CurveBindingUtility.s_Root == null)
            {
                CurveBindingUtility.s_Root = CurveBindingUtility.CreateNewGameObject(null, "Root");
            }
            if (path.Length == 0)
            {
                return(CurveBindingUtility.s_Root);
            }
            string[] array = path.Split(new char[]
            {
                '/'
            });
            Transform transform = CurveBindingUtility.s_Root.transform;

            string[] array2 = array;
            for (int i = 0; i < array2.Length; i++)
            {
                string    name       = array2[i];
                Transform transform2 = transform.FindChild(name);
                if (transform2 == null)
                {
                    transform = CurveBindingUtility.CreateNewGameObject(transform, name).transform;
                }
                else
                {
                    transform = transform2;
                }
            }
            return(transform.gameObject);
        }
        static private void ProcessVector3Modification(IAnimationRecordingState state, EditorCurveBinding baseBinding, UndoPropertyModification modification, Transform target, string axis, float scale = 1.0f)
        {
            var binding = baseBinding;

            binding.propertyName = binding.propertyName.Remove(binding.propertyName.Length - 1, 1) + axis;

            object currentValue = CurveBindingUtility.GetCurrentValue(state.activeRootGameObject, binding);

            var previousModification = modification.previousValue;

            if (previousModification == null)
            {
                // create dummy
                previousModification              = new PropertyModification();
                previousModification.target       = target;
                previousModification.propertyPath = binding.propertyName;
                previousModification.value        = ((float)currentValue).ToString(CultureInfo.InvariantCulture.NumberFormat);
            }

            object previousValue = currentValue;

            ValueFromPropertyModification(previousModification, binding, out previousValue);

            state.AddPropertyModification(binding, previousModification, modification.keepPrefabOverride);

            if (scale != 1.0f)
            {
                previousValue = (object)((float)previousValue / scale);
                currentValue  = (object)((float)currentValue / scale);
            }

            AddKey(state, binding, typeof(float), previousValue, currentValue);
        }
Exemple #4
0
        static public void ProcessModifications(IAnimationRecordingState state, UndoPropertyModification[] modifications)
        {
            AnimationClip clip = state.activeAnimationClip;
            GameObject    root = state.activeRootGameObject;

            // Record modified properties
            for (int i = 0; i < modifications.Length; i++)
            {
                EditorCurveBinding binding = new EditorCurveBinding();

                PropertyModification prop = modifications[i].previousValue;
                Type type = AnimationUtility.PropertyModificationToEditorCurveBinding(prop, root, out binding);
                if (type != null)
                {
                    object currentValue = CurveBindingUtility.GetCurrentValue(root, binding);

                    object previousValue = null;
                    if (!ValueFromPropertyModification(prop, binding, out previousValue))
                    {
                        previousValue = currentValue;
                    }

                    state.AddPropertyModification(binding, prop, modifications[i].keepPrefabOverride);
                    AddKey(state, binding, type, previousValue, currentValue);
                }
            }
        }
 public static object GetCurrentValue(GameObject rootGameObject, EditorCurveBinding curveBinding)
 {
     if (rootGameObject != null)
     {
         return(AnimationWindowUtility.GetCurrentValue(rootGameObject, curveBinding));
     }
     return(CurveBindingUtility.GetCurrentValue(curveBinding));
 }
 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);
        }
 private static void PrepareHierarchy(AnimationClip clip)
 {
   foreach (EditorCurveBinding curveBinding in AnimationUtility.GetCurveBindings(clip))
   {
     GameObject orGetGameObject = CurveBindingUtility.CreateOrGetGameObject(curveBinding.path);
     if ((UnityEngine.Object) orGetGameObject.GetComponent(curveBinding.type) == (UnityEngine.Object) null)
       orGetGameObject.AddComponent(curveBinding.type);
   }
 }
Exemple #9
0
        private static void PrepareHierarchy(EditorCurveBinding curveBinding)
        {
            GameObject gameObject = CurveBindingUtility.CreateOrGetGameObject(curveBinding.path);

            if (gameObject.GetComponent(curveBinding.type) == null)
            {
                gameObject.AddComponent(curveBinding.type);
            }
        }
 public static void SampleAnimationClip(GameObject rootGameObject, AnimationClip clip, float time)
 {
     if (rootGameObject != null)
     {
         AnimationMode.SampleAnimationClip(rootGameObject, clip, time);
     }
     else
     {
         CurveBindingUtility.SampleAnimationClip(clip, time);
     }
 }
Exemple #11
0
 private static void PrepareHierarchy(AnimationClip clip)
 {
     EditorCurveBinding[] curveBindings = AnimationUtility.GetCurveBindings(clip);
     EditorCurveBinding[] array         = curveBindings;
     for (int i = 0; i < array.Length; i++)
     {
         EditorCurveBinding editorCurveBinding = array[i];
         GameObject         gameObject         = CurveBindingUtility.CreateOrGetGameObject(editorCurveBinding.path);
         if (gameObject.GetComponent(editorCurveBinding.type) == null)
         {
             gameObject.AddComponent(editorCurveBinding.type);
         }
     }
 }
        private static void PrepareHierarchy(EditorCurveBinding curveBinding)
        {
            GameObject gameObject = CurveBindingUtility.CreateOrGetGameObject(curveBinding.path);

            if (gameObject.GetComponent(curveBinding.type) == null)
            {
                Component component = gameObject.AddComponent(curveBinding.type);
                Behaviour behaviour = component as Behaviour;
                if (behaviour != null)
                {
                    behaviour.enabled = false;
                }
            }
        }
 private static GameObject CreateOrGetGameObject(string path)
 {
   if ((UnityEngine.Object) CurveBindingUtility.s_Root == (UnityEngine.Object) null)
     CurveBindingUtility.s_Root = CurveBindingUtility.CreateNewGameObject((Transform) null, "Root");
   if (path.Length == 0)
     return CurveBindingUtility.s_Root;
   string[] strArray = path.Split('/');
   Transform parent = CurveBindingUtility.s_Root.transform;
   foreach (string name in strArray)
   {
     Transform child = parent.FindChild(name);
     parent = !((UnityEngine.Object) child == (UnityEngine.Object) null) ? child : CurveBindingUtility.CreateNewGameObject(parent, name).transform;
   }
   return parent.gameObject;
 }
Exemple #14
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);
        }
Exemple #15
0
        private static void ProcessVector3Modification(IAnimationRecordingState state, EditorCurveBinding baseBinding, UndoPropertyModification modification, Transform target, string axis)
        {
            EditorCurveBinding   editorCurveBinding   = baseBinding;
            PropertyModification propertyModification = modification.previousValue;

            editorCurveBinding.propertyName = editorCurveBinding.propertyName.Remove(editorCurveBinding.propertyName.Length - 1, 1) + axis;
            if (propertyModification == null)
            {
                propertyModification              = new PropertyModification();
                propertyModification.target       = target;
                propertyModification.propertyPath = editorCurveBinding.propertyName;
                object currentValue = CurveBindingUtility.GetCurrentValue(state.activeRootGameObject, editorCurveBinding);
                propertyModification.value = ((float)currentValue).ToString();
            }
            state.AddPropertyModification(editorCurveBinding, propertyModification, modification.keepPrefabOverride);
            AnimationRecording.AddKey(state, editorCurveBinding, typeof(float), propertyModification);
        }
        public static AnimationWindowCurve CreateDefaultCurve(AnimationWindowSelectionItem selectionItem, EditorCurveBinding binding)
        {
            AnimationClip        animationClip        = selectionItem.animationClip;
            Type                 editorCurveValueType = selectionItem.GetEditorCurveValueType(binding);
            AnimationWindowCurve animationWindowCurve = new AnimationWindowCurve(animationClip, binding, editorCurveValueType);
            object               currentValue         = CurveBindingUtility.GetCurrentValue(selectionItem.rootGameObject, binding);

            if (animationClip.length == 0f)
            {
                AnimationWindowUtility.AddKeyframeToCurve(animationWindowCurve, currentValue, editorCurveValueType, AnimationKeyTime.Time(0f, animationClip.frameRate));
            }
            else
            {
                AnimationWindowUtility.AddKeyframeToCurve(animationWindowCurve, currentValue, editorCurveValueType, AnimationKeyTime.Time(0f, animationClip.frameRate));
                AnimationWindowUtility.AddKeyframeToCurve(animationWindowCurve, currentValue, editorCurveValueType, AnimationKeyTime.Time(animationClip.length, animationClip.frameRate));
            }
            return(animationWindowCurve);
        }
        private static PropertyModification CreateDummyPropertyModification(GameObject root, PropertyModification baseProperty, EditorCurveBinding binding)
        {
            PropertyModification propertyModification = new PropertyModification();

            propertyModification.target       = baseProperty.target;
            propertyModification.propertyPath = binding.propertyName;
            object currentValue = CurveBindingUtility.GetCurrentValue(root, binding);

            if (binding.isPPtrCurve)
            {
                propertyModification.objectReference = (UnityEngine.Object)currentValue;
            }
            else
            {
                propertyModification.value = ((float)currentValue).ToString();
            }
            return(propertyModification);
        }
        public static void AddKeyframes(AnimationWindowState state, AnimationWindowCurve[] curves, AnimationKeyTime time)
        {
            string undoLabel = "Add Key";

            state.SaveKeySelection(undoLabel);
            state.ClearKeySelections();
            foreach (AnimationWindowCurve curve in curves)
            {
                if (curve.animationIsEditable)
                {
                    AnimationKeyTime        time2        = AnimationKeyTime.Time(time.time - curve.timeOffset, time.frameRate);
                    object                  currentValue = CurveBindingUtility.GetCurrentValue(state, curve);
                    AnimationWindowKeyframe keyframe     = AddKeyframeToCurve(curve, currentValue, curve.valueType, time2);
                    state.SaveCurve(curve, undoLabel);
                    state.SelectKey(keyframe);
                }
            }
        }
Exemple #19
0
        public static void AddKeyframes(AnimationWindowState state, AnimationWindowCurve[] curves, AnimationKeyTime time)
        {
            string undoLabel = "Add Key";

            state.SaveKeySelection(undoLabel);
            state.ClearKeySelections();
            for (int i = 0; i < curves.Length; i++)
            {
                AnimationWindowCurve animationWindowCurve = curves[i];
                if (animationWindowCurve.animationIsEditable)
                {
                    AnimationKeyTime        time2        = AnimationKeyTime.Time(time.time - animationWindowCurve.timeOffset, time.frameRate);
                    object                  currentValue = CurveBindingUtility.GetCurrentValue(state, animationWindowCurve);
                    AnimationWindowKeyframe keyframe     = AnimationWindowUtility.AddKeyframeToCurve(animationWindowCurve, currentValue, animationWindowCurve.valueType, time2);
                    state.SaveCurve(animationWindowCurve, undoLabel);
                    state.SelectKey(keyframe);
                }
            }
        }
 private static void PrepareHierarchy(AnimationClip clip)
 {
     EditorCurveBinding[] curveBindings = AnimationUtility.GetCurveBindings(clip);
     EditorCurveBinding[] array         = curveBindings;
     for (int i = 0; i < array.Length; i++)
     {
         EditorCurveBinding editorCurveBinding = array[i];
         GameObject         gameObject         = CurveBindingUtility.CreateOrGetGameObject(editorCurveBinding.path);
         if (gameObject.GetComponent(editorCurveBinding.type) == null)
         {
             Component component = gameObject.AddComponent(editorCurveBinding.type);
             Behaviour behaviour = component as Behaviour;
             if (behaviour != null)
             {
                 behaviour.enabled = false;
             }
         }
     }
 }
Exemple #21
0
        static private void ProcessVector3Modification(IAnimationRecordingState state, EditorCurveBinding baseBinding, UndoPropertyModification modification, Transform target, string axis)
        {
            var binding  = baseBinding;
            var property = modification.previousValue;

            binding.propertyName = binding.propertyName.Remove(binding.propertyName.Length - 1, 1) + axis;

            if (property == null)
            {
                // create dummy
                property              = new PropertyModification();
                property.target       = target;
                property.propertyPath = binding.propertyName;
                object currentValue = CurveBindingUtility.GetCurrentValue(state.activeRootGameObject, binding);
                property.value = ((float)currentValue).ToString();
            }

            state.AddPropertyModification(binding, property, modification.keepPrefabOverride);
            AddKey(state, binding, typeof(float), property);
        }
        private static void AddKey(AnimationWindowState state, EditorCurveBinding binding, Type type, PropertyModification modification)
        {
            GameObject           activeRootGameObject = state.activeRootGameObject;
            AnimationClip        activeAnimationClip  = state.activeAnimationClip;
            AnimationWindowCurve curve = new AnimationWindowCurve(activeAnimationClip, binding, type);
            object currentValue        = CurveBindingUtility.GetCurrentValue(activeRootGameObject, binding);

            if (curve.length == 0)
            {
                object outObject = null;
                if (!ValueFromPropertyModification(modification, binding, out outObject))
                {
                    outObject = currentValue;
                }
                if (state.frame != 0)
                {
                    AnimationWindowUtility.AddKeyframeToCurve(curve, outObject, type, AnimationKeyTime.Frame(0, activeAnimationClip.frameRate));
                }
            }
            AnimationWindowUtility.AddKeyframeToCurve(curve, currentValue, type, AnimationKeyTime.Frame(state.frame, activeAnimationClip.frameRate));
            state.SaveCurve(curve);
        }
Exemple #23
0
        static void AddKey(IAnimationRecordingState state, EditorCurveBinding binding, Type type, PropertyModification modification)
        {
            GameObject    root = state.activeRootGameObject;
            AnimationClip clip = state.activeAnimationClip;

            if ((clip.hideFlags & HideFlags.NotEditable) != 0)
            {
                return;
            }

            AnimationWindowCurve curve = new AnimationWindowCurve(clip, binding, type);

            // Add key at current frame
            object currentValue = CurveBindingUtility.GetCurrentValue(root, binding);

            if (state.addZeroFrame)
            {
                // Is it a new curve?
                if (curve.length == 0)
                {
                    object oldValue = null;
                    if (!ValueFromPropertyModification(modification, binding, out oldValue))
                    {
                        oldValue = currentValue;
                    }

                    if (state.currentFrame != 0)
                    {
                        AnimationWindowUtility.AddKeyframeToCurve(curve, oldValue, type, AnimationKeyTime.Frame(0, clip.frameRate));
                    }
                }
            }

            AnimationWindowUtility.AddKeyframeToCurve(curve, currentValue, type, AnimationKeyTime.Frame(state.currentFrame, clip.frameRate));

            state.SaveCurve(curve);
        }
        private void DoValueField(Rect rect, AnimationWindowHierarchyNode node, int row)
        {
            bool curvesChanged = false;

            if (node is AnimationWindowHierarchyPropertyNode)
            {
                AnimationWindowCurve[] curves = node.curves;
                if (curves == null || curves.Length == 0)
                {
                    return;
                }

                // We do valuefields for dopelines that only have single curve
                AnimationWindowCurve curve = curves[0];
                object objectValue         = CurveBindingUtility.GetCurrentValue(state, curve);

                if (objectValue is float)
                {
                    float value = (float)objectValue;

                    Rect valueFieldDragRect = new Rect(rect.xMax - k_ValueFieldOffsetFromRightSide - k_ValueFieldDragWidth, rect.y, k_ValueFieldDragWidth, rect.height);
                    Rect valueFieldRect     = new Rect(rect.xMax - k_ValueFieldOffsetFromRightSide, rect.y, k_ValueFieldWidth, rect.height);

                    if (Event.current.type == EventType.MouseMove && valueFieldRect.Contains(Event.current.mousePosition))
                    {
                        s_WasInsideValueRectFrame = Time.frameCount;
                    }

                    EditorGUI.BeginChangeCheck();

                    if (curve.valueType == typeof(bool))
                    {
                        value = GUI.Toggle(valueFieldRect, m_HierarchyItemValueControlIDs[row], value != 0, GUIContent.none, EditorStyles.toggle) ? 1 : 0;
                    }
                    else
                    {
                        int  id = m_HierarchyItemValueControlIDs[row];
                        bool enterInTextField = (EditorGUIUtility.keyboardControl == id &&
                                                 EditorGUIUtility.editingTextField &&
                                                 Event.current.type == EventType.KeyDown &&
                                                 (Event.current.character == '\n' || (int)Event.current.character == 3));

                        //  Force back keyboard focus to float field editor when editing it.
                        //  TreeView forces keyboard focus on itself at mouse down and we lose focus here.
                        if (EditorGUI.s_RecycledEditor.controlID == id && Event.current.type == EventType.MouseDown && valueFieldRect.Contains(Event.current.mousePosition))
                        {
                            GUIUtility.keyboardControl = id;
                        }

                        value = EditorGUI.DoFloatField(EditorGUI.s_RecycledEditor,
                                                       valueFieldRect,
                                                       valueFieldDragRect,
                                                       id,
                                                       value,
                                                       "g5",
                                                       m_AnimationSelectionTextField,
                                                       true);
                        if (enterInTextField)
                        {
                            GUI.changed = true;
                            Event.current.Use();
                        }
                    }

                    if (float.IsInfinity(value) || float.IsNaN(value))
                    {
                        value = 0;
                    }

                    if (EditorGUI.EndChangeCheck())
                    {
                        string undoLabel = "Edit Key";

                        AnimationKeyTime newAnimationKeyTime = AnimationKeyTime.Time(state.currentTime, curve.clip.frameRate);

                        AnimationWindowKeyframe existingKeyframe = null;
                        foreach (AnimationWindowKeyframe keyframe in curve.m_Keyframes)
                        {
                            if (Mathf.Approximately(keyframe.time, state.currentTime))
                            {
                                existingKeyframe = keyframe;
                            }
                        }

                        if (existingKeyframe == null)
                        {
                            AnimationWindowUtility.AddKeyframeToCurve(curve, value, curve.valueType, newAnimationKeyTime);
                        }
                        else
                        {
                            existingKeyframe.value = value;
                        }

                        state.SaveCurve(curve.clip, curve, undoLabel);
                        curvesChanged = true;
                    }
                }
            }

            if (curvesChanged)
            {
                state.ResampleAnimation();
            }
        }
Exemple #25
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 static void SampleAnimationClip(AnimationClip clip, float time)
 {
     CurveBindingUtility.PrepareHierarchy(clip);
     AnimationMode.SampleAnimationClip(CurveBindingUtility.s_Root, clip, time);
 }
 private static object GetCurrentValue(EditorCurveBinding curveBinding)
 {
     CurveBindingUtility.PrepareHierarchy(curveBinding);
     return(AnimationWindowUtility.GetCurrentValue(CurveBindingUtility.s_Root, curveBinding));
 }
 private static Type GetEditorCurveValueType(EditorCurveBinding curveBinding)
 {
     CurveBindingUtility.PrepareHierarchy(curveBinding);
     return(AnimationUtility.GetEditorCurveValueType(CurveBindingUtility.s_Root, curveBinding));
 }
 public static object GetCurrentValue(GameObject rootGameObject, EditorCurveBinding curveBinding)
 {
   if ((UnityEngine.Object) rootGameObject != (UnityEngine.Object) null)
     return AnimationWindowUtility.GetCurrentValue(rootGameObject, curveBinding);
   return CurveBindingUtility.GetCurrentValue(curveBinding);
 }
        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();
                }
            }
        }