public static object GetCurrentValue(GameObject rootGameObject, EditorCurveBinding curveBinding)
 {
     if (rootGameObject != null)
     {
         return(AnimationWindowUtility.GetCurrentValue(rootGameObject, curveBinding));
     }
     return(GetCurrentValue(curveBinding));
 }
 public static object GetCurrentValue(AnimationWindowState state, AnimationWindowCurve curve)
 {
     if (UnityEditor.AnimationMode.InAnimationMode() && (curve.rootGameObject != null))
     {
         return(AnimationWindowUtility.GetCurrentValue(curve.rootGameObject, curve.binding));
     }
     return(curve.Evaluate(state.currentTime - curve.timeOffset));
 }
Esempio n. 3
0
        public static AnimationWindowKeyframe AddKeyframeToCurve(AnimationWindowState state, AnimationWindowCurve curve, AnimationKeyTime time)
        {
            object currentValue            = AnimationWindowUtility.GetCurrentValue(state.m_RootGameObject, curve.binding);
            Type   editorCurveValueType    = AnimationUtility.GetEditorCurveValueType(state.m_RootGameObject, curve.binding);
            AnimationWindowKeyframe result = AnimationWindowUtility.AddKeyframeToCurve(curve, currentValue, editorCurveValueType, time);

            state.SaveCurve(curve);
            return(result);
        }
Esempio n. 4
0
 // Retrieve current value.  If bindings are available and value is animated, use bindings to get value.
 // Otherwise, evaluate AnimationWindowCurve at current time.
 public static object GetCurrentValue(AnimationWindowState state, AnimationWindowCurve curve)
 {
     if (state.previewing && curve.rootGameObject != null)
     {
         return(AnimationWindowUtility.GetCurrentValue(curve.rootGameObject, curve.binding));
     }
     else
     {
         return(curve.Evaluate(state.currentTime));
     }
 }
Esempio n. 5
0
        public static object GetCurrentValue(AnimationWindowState state, AnimationWindowCurve curve)
        {
            object result;

            if (AnimationMode.InAnimationMode() && curve.rootGameObject != null)
            {
                result = AnimationWindowUtility.GetCurrentValue(curve.rootGameObject, curve.binding);
            }
            else
            {
                result = curve.Evaluate(state.currentTime - curve.timeOffset);
            }
            return(result);
        }
Esempio n. 6
0
        public static AnimationWindowCurve CreateDefaultCurve(AnimationClip clip, GameObject rootGameObject, EditorCurveBinding binding)
        {
            Type editorCurveValueType = AnimationUtility.GetEditorCurveValueType(rootGameObject, binding);
            AnimationWindowCurve animationWindowCurve = new AnimationWindowCurve(clip, binding, editorCurveValueType);
            object currentValue = AnimationWindowUtility.GetCurrentValue(rootGameObject, binding);

            if (clip.length == 0f)
            {
                AnimationWindowUtility.AddKeyframeToCurve(animationWindowCurve, currentValue, editorCurveValueType, AnimationKeyTime.Time(0f, clip.frameRate));
            }
            else
            {
                AnimationWindowUtility.AddKeyframeToCurve(animationWindowCurve, currentValue, editorCurveValueType, AnimationKeyTime.Time(0f, clip.frameRate));
                AnimationWindowUtility.AddKeyframeToCurve(animationWindowCurve, currentValue, editorCurveValueType, AnimationKeyTime.Time(clip.length, clip.frameRate));
            }
            return(animationWindowCurve);
        }
Esempio n. 7
0
        public static object GetCurrentValue(GameObject rootGameObject, EditorCurveBinding curveBinding)
        {
            object result;

            if (rootGameObject != null)
            {
                result = AnimationWindowUtility.GetCurrentValue(rootGameObject, curveBinding);
            }
            else if (curveBinding.isPPtrCurve)
            {
                result = null;
            }
            else
            {
                result = 0f;
            }
            return(result);
        }
        private static void AddKey(AnimationWindowState state, EditorCurveBinding binding, Type type, PropertyModification modification)
        {
            GameObject           rootGameObject       = state.m_RootGameObject;
            AnimationClip        activeAnimationClip  = state.m_ActiveAnimationClip;
            AnimationWindowCurve animationWindowCurve = new AnimationWindowCurve(activeAnimationClip, binding, type);
            object currentValue = AnimationWindowUtility.GetCurrentValue(rootGameObject, binding);
            object value        = null;

            if (animationWindowCurve.length == 0 && state.m_Frame != 0)
            {
                if (!AnimationRecording.ValueFromPropertyModification(modification, binding, out value))
                {
                    value = currentValue;
                }
                AnimationWindowUtility.AddKeyframeToCurve(animationWindowCurve, value, type, AnimationKeyTime.Frame(0, activeAnimationClip.frameRate));
            }
            AnimationWindowUtility.AddKeyframeToCurve(animationWindowCurve, currentValue, type, AnimationKeyTime.Frame(state.m_Frame, activeAnimationClip.frameRate));
            state.SaveCurve(animationWindowCurve);
        }
Esempio n. 9
0
 // Retrieve Current Value.  Use specified bindings to do so.
 public static object GetCurrentValue(GameObject rootGameObject, EditorCurveBinding curveBinding)
 {
     if (rootGameObject != null)
     {
         return(AnimationWindowUtility.GetCurrentValue(rootGameObject, curveBinding));
     }
     else
     {
         if (curveBinding.isPPtrCurve)
         {
             // Cannot extract type of PPtrCurve.
             return(null);
         }
         else
         {
             // Cannot extract type of AnimationCurve.  Default to float.
             return(0.0f);
         }
     }
 }
 private static object GetCurrentValue(EditorCurveBinding curveBinding)
 {
     PrepareHierarchy(curveBinding);
     return(AnimationWindowUtility.GetCurrentValue(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)
 {
     if (!AnimationMode.InAnimationMode())
     {
         return;
     }
     EditorGUI.BeginDisabledGroup(this.state.IsReadOnly);
     if (node is AnimationWindowHierarchyPropertyNode)
     {
         List <AnimationWindowCurve> curves = this.state.GetCurves(node, false);
         if (curves == null || curves.Count == 0)
         {
             return;
         }
         AnimationWindowCurve animationWindowCurve = curves[0];
         object currentValue         = AnimationWindowUtility.GetCurrentValue(this.state.m_RootGameObject, animationWindowCurve.binding);
         Type   editorCurveValueType = AnimationUtility.GetEditorCurveValueType(this.state.m_RootGameObject, 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 flag      = GUIUtility.keyboardControl == controlID && EditorGUIUtility.editingTextField && Event.current.type == EventType.KeyDown && (Event.current.character == '\n' || Event.current.character == '\u0003');
                 num = EditorGUI.DoFloatField(EditorGUI.s_RecycledEditor, position, new Rect(0f, 0f, 0f, 0f), controlID, num, EditorGUI.kFloatFieldFormatString, this.animationSelectionTextField, false);
                 if (flag)
                 {
                     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);
             }
         }
     }
     EditorGUI.EndDisabledGroup();
 }