public static void AddSelectedKeyframes(AnimationWindowState state, AnimationKeyTime time) { foreach (AnimationWindowCurve current in state.activeCurves) { AnimationWindowUtility.AddKeyframeToCurve(state, current, time); } }
private static void AddRotationKey(IAnimationRecordingState state, EditorCurveBinding binding, Type type, Vector3 previousEulerAngles, Vector3 currentEulerAngles) { AnimationClip activeAnimationClip = state.activeAnimationClip; if ((activeAnimationClip.hideFlags & HideFlags.NotEditable) == HideFlags.None) { EditorCurveBinding[] array = RotationCurveInterpolation.RemapAnimationBindingForRotationAddKey(binding, activeAnimationClip); for (int i = 0; i < 3; i++) { AnimationWindowCurve animationWindowCurve = new AnimationWindowCurve(activeAnimationClip, array[i], type); if (state.addZeroFrame) { if (animationWindowCurve.length == 0) { if (state.currentFrame != 0) { AnimationWindowUtility.AddKeyframeToCurve(animationWindowCurve, previousEulerAngles[i], type, AnimationKeyTime.Frame(0, activeAnimationClip.frameRate)); } } } AnimationWindowUtility.AddKeyframeToCurve(animationWindowCurve, currentEulerAngles[i], type, AnimationKeyTime.Frame(state.currentFrame, activeAnimationClip.frameRate)); state.SaveCurve(animationWindowCurve); } } }
static void AddKey(IAnimationRecordingState state, EditorCurveBinding binding, Type type, object previousValue, object currentValue) { AnimationClip clip = state.activeAnimationClip; if ((clip.hideFlags & HideFlags.NotEditable) != 0) { return; } AnimationWindowCurve curve = new AnimationWindowCurve(clip, binding, type); // Add previous value at first frame on empty curves. if (state.addZeroFrame) { // Is it a new curve? if (curve.length == 0) { if (state.currentFrame != 0) { // case 1373924 // In the case of a new curve, we also have to convert the previousValue to float for a discrete int if (binding.isDiscreteCurve) { previousValue = UnityEngine.Animations.DiscreteEvaluationAttributeUtilities.ConvertDiscreteIntToFloat((int)previousValue); } AnimationWindowUtility.AddKeyframeToCurve(curve, previousValue, type, AnimationKeyTime.Frame(0, clip.frameRate)); } } } // Add key at current frame. AnimationWindowUtility.AddKeyframeToCurve(curve, currentValue, type, AnimationKeyTime.Frame(state.currentFrame, clip.frameRate)); state.SaveCurve(curve); }
public static void AddSelectedKeyframes(AnimationWindowState state, AnimationKeyTime time) { if (state.activeCurves.Count > 0) { using (List <AnimationWindowCurve> .Enumerator enumerator = state.activeCurves.GetEnumerator()) { while (enumerator.MoveNext()) { AnimationWindowCurve current = enumerator.Current; AnimationWindowUtility.AddKeyframeToCurve(state, current, time); } } } else { using (List <AnimationWindowCurve> .Enumerator enumerator = state.allCurves.GetEnumerator()) { while (enumerator.MoveNext()) { AnimationWindowCurve current = enumerator.Current; AnimationWindowUtility.AddKeyframeToCurve(state, current, time); } } } }
static void AddRotationKey(IAnimationRecordingState state, EditorCurveBinding binding, Type type, Vector3 previousEulerAngles, Vector3 currentEulerAngles) { AnimationClip clip = state.activeAnimationClip; if ((clip.hideFlags & HideFlags.NotEditable) != 0) { return; } EditorCurveBinding[] additionalBindings = RotationCurveInterpolation.RemapAnimationBindingForRotationAddKey(binding, clip); // Add key at current frame for (int i = 0; i < 3; i++) { AnimationWindowCurve curve = new AnimationWindowCurve(clip, additionalBindings[i], type); if (state.addZeroFrame) { // Is it a new curve? if (curve.length == 0) { if (state.currentFrame != 0) { AnimationWindowUtility.AddKeyframeToCurve(curve, previousEulerAngles[i], type, AnimationKeyTime.Frame(0, clip.frameRate)); } } } AnimationWindowUtility.AddKeyframeToCurve(curve, currentEulerAngles[i], type, AnimationKeyTime.Frame(state.currentFrame, clip.frameRate)); state.SaveCurve(curve); } }
private void AddKeysAtCurrentTime(List <AnimationWindowCurve> curves) { foreach (AnimationWindowCurve current in curves) { AnimationWindowUtility.AddKeyframeToCurve(this.state, current, this.state.time); } }
static void AddKey(IAnimationRecordingState state, EditorCurveBinding binding, Type type, object previousValue, object currentValue) { AnimationClip clip = state.activeAnimationClip; if ((clip.hideFlags & HideFlags.NotEditable) != 0) { return; } AnimationWindowCurve curve = new AnimationWindowCurve(clip, binding, type); // Add previous value at first frame on empty curves. if (state.addZeroFrame) { // Is it a new curve? if (curve.length == 0) { if (state.currentFrame != 0) { AnimationWindowUtility.AddKeyframeToCurve(curve, previousValue, type, AnimationKeyTime.Frame(0, clip.frameRate)); } } } // Add key at current frame. AnimationWindowUtility.AddKeyframeToCurve(curve, currentValue, type, AnimationKeyTime.Frame(state.currentFrame, clip.frameRate)); state.SaveCurve(curve); }
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) { 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); } }
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); }
private void AddKeysAtCurrentTime(List <AnimationWindowCurve> curves) { using (List <AnimationWindowCurve> .Enumerator enumerator = curves.GetEnumerator()) { while (enumerator.MoveNext()) { AnimationWindowUtility.AddKeyframeToCurve(this.state, enumerator.Current, this.state.time); } } }
public static AnimationWindowKeyframe AddKeyframeToCurve(AnimationWindowState state, AnimationWindowCurve curve, AnimationKeyTime time) { object currentValue = CurveBindingUtility.GetCurrentValue(state.activeRootGameObject, curve.binding); System.Type editorCurveValueType = CurveBindingUtility.GetEditorCurveValueType(state.activeRootGameObject, curve.binding); AnimationWindowKeyframe curve1 = AnimationWindowUtility.AddKeyframeToCurve(curve, currentValue, editorCurveValueType, time); state.SaveCurve(curve); return(curve1); }
public static void AddSelectedKeyframes(AnimationWindowState state, AnimationKeyTime time) { List <AnimationWindowCurve> list = (state.activeCurves.Count <= 0) ? state.allCurves : state.activeCurves; foreach (AnimationWindowCurve current in list) { if (current.animationIsEditable) { AnimationWindowUtility.AddKeyframeToCurve(state, current, AnimationKeyTime.Time(time.time - current.timeOffset, time.frameRate)); } } }
static void ProcessAnimatorModification(IAnimationRecordingState state, Animator animator, UndoPropertyModification modification, string name, float value, float scale) { AnimationClip clip = state.activeAnimationClip; if ((clip.hideFlags & HideFlags.NotEditable) != 0) { return; } float prevValue = value; object oValue; if (ValueFromPropertyModification(modification.currentValue, new EditorCurveBinding(), out oValue)) { value = (float)oValue; } if (ValueFromPropertyModification(modification.previousValue, new EditorCurveBinding(), out oValue)) { prevValue = (float)oValue; } value = Mathf.Abs(scale) > Mathf.Epsilon ? value / scale : value; prevValue = Mathf.Abs(scale) > Mathf.Epsilon ? prevValue / scale : prevValue; var binding = new EditorCurveBinding(); binding.propertyName = name; binding.path = ""; binding.type = typeof(Animator); var prop = new PropertyModification(); prop.target = animator; prop.propertyPath = binding.propertyName; prop.value = value.ToString(); state.AddPropertyModification(binding, prop, modification.keepPrefabOverride); AnimationWindowCurve curve = new AnimationWindowCurve(clip, binding, typeof(float)); if (state.addZeroFrame && state.currentFrame != 0 && curve.length == 0) { AnimationWindowUtility.AddKeyframeToCurve(curve, prevValue, typeof(float), AnimationKeyTime.Frame(0, clip.frameRate)); } AnimationWindowUtility.AddKeyframeToCurve(curve, value, typeof(float), AnimationKeyTime.Frame(state.currentFrame, clip.frameRate)); state.SaveCurve(curve); }
public static AnimationWindowCurve CreateDefaultCurve(AnimationClip clip, GameObject rootGameObject, EditorCurveBinding binding) { System.Type editorCurveValueType = CurveBindingUtility.GetEditorCurveValueType(rootGameObject, binding); AnimationWindowCurve curve = new AnimationWindowCurve(clip, binding, editorCurveValueType); object currentValue = CurveBindingUtility.GetCurrentValue(rootGameObject, binding); if ((double)clip.length == 0.0) { AnimationWindowUtility.AddKeyframeToCurve(curve, currentValue, editorCurveValueType, AnimationKeyTime.Time(0.0f, clip.frameRate)); } else { AnimationWindowUtility.AddKeyframeToCurve(curve, currentValue, editorCurveValueType, AnimationKeyTime.Time(0.0f, clip.frameRate)); AnimationWindowUtility.AddKeyframeToCurve(curve, currentValue, editorCurveValueType, AnimationKeyTime.Time(clip.length, clip.frameRate)); } return(curve); }
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 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); }
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 AddRotationKey(AnimationWindowState state, EditorCurveBinding binding, System.Type type, Vector3 previousEulerAngles, Vector3 currentEulerAngles) { AnimationClip activeAnimationClip = state.activeAnimationClip; if ((activeAnimationClip.hideFlags & HideFlags.NotEditable) != HideFlags.None) { return; } EditorCurveBinding[] editorCurveBindingArray = RotationCurveInterpolation.RemapAnimationBindingForRotationAddKey(binding, activeAnimationClip); for (int index = 0; index < 3; ++index) { AnimationWindowCurve curve = new AnimationWindowCurve(activeAnimationClip, editorCurveBindingArray[index], type); if (curve.length == 0 && state.frame != 0) { AnimationWindowUtility.AddKeyframeToCurve(curve, (object)previousEulerAngles[index], type, AnimationKeyTime.Frame(0, activeAnimationClip.frameRate)); } AnimationWindowUtility.AddKeyframeToCurve(curve, (object)currentEulerAngles[index], type, AnimationKeyTime.Frame(state.frame, activeAnimationClip.frameRate)); state.SaveCurve(curve); } }
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); }
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 static void ProcessAnimatorModification(IAnimationRecordingState state, Animator animator, UndoPropertyModification modification, string name, float value, float scale) { AnimationClip activeAnimationClip = state.activeAnimationClip; if ((activeAnimationClip.hideFlags & HideFlags.NotEditable) == HideFlags.None) { float num = value; object obj; if (AnimationRecording.ValueFromPropertyModification(modification.currentValue, default(EditorCurveBinding), out obj)) { value = (float)obj; } if (AnimationRecording.ValueFromPropertyModification(modification.previousValue, default(EditorCurveBinding), out obj)) { num = (float)obj; } value = ((Mathf.Abs(scale) <= Mathf.Epsilon) ? value : (value / scale)); num = ((Mathf.Abs(scale) <= Mathf.Epsilon) ? num : (num / scale)); EditorCurveBinding binding = default(EditorCurveBinding); binding.propertyName = name; binding.path = ""; binding.type = typeof(Animator); PropertyModification propertyModification = new PropertyModification(); propertyModification.target = animator; propertyModification.propertyPath = binding.propertyName; propertyModification.value = value.ToString(); state.AddPropertyModification(binding, propertyModification, modification.keepPrefabOverride); AnimationWindowCurve animationWindowCurve = new AnimationWindowCurve(activeAnimationClip, binding, typeof(float)); if (state.addZeroFrame && state.currentFrame != 0 && animationWindowCurve.length == 0) { AnimationWindowUtility.AddKeyframeToCurve(animationWindowCurve, num, typeof(float), AnimationKeyTime.Frame(0, activeAnimationClip.frameRate)); } AnimationWindowUtility.AddKeyframeToCurve(animationWindowCurve, value, typeof(float), AnimationKeyTime.Frame(state.currentFrame, activeAnimationClip.frameRate)); state.SaveCurve(animationWindowCurve); } }
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(); } }
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 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(); }
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 value = CurveBindingUtility.GetCurrentValue(state, curve); if (!curve.isPPtrCurve) { 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], (float)value != 0, GUIContent.none, EditorStyles.toggle) ? 1f : 0f; } 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; } if (curve.isDiscreteCurve) { value = EditorGUI.DoIntField(EditorGUI.s_RecycledEditor, valueFieldRect, valueFieldDragRect, id, (int)value, EditorGUI.kIntFieldFormatString, m_AnimationSelectionTextField, true, 0); if (enterInTextField) { GUI.changed = true; Event.current.Use(); } } else { value = EditorGUI.DoFloatField(EditorGUI.s_RecycledEditor, valueFieldRect, valueFieldDragRect, id, (float)value, "g5", m_AnimationSelectionTextField, true); if (enterInTextField) { GUI.changed = true; Event.current.Use(); } if (float.IsInfinity((float)value) || float.IsNaN((float)value)) { value = 0f; } } } if (EditorGUI.EndChangeCheck()) { string undoLabel = "Edit Key"; AnimationKeyTime newAnimationKeyTime = AnimationKeyTime.Time(state.currentTime, curve.clip.frameRate); AnimationWindowUtility.AddKeyframeToCurve(curve, value, curve.valueType, newAnimationKeyTime); state.SaveCurve(curve.clip, curve, undoLabel); curvesChanged = true; } } } if (curvesChanged) { //Fix for case 1382193: Stop recording any candidates if a property value field is modified if (AnimationMode.IsRecordingCandidates()) { state.ClearCandidates(); } 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(); } } }
private void DoValueField(Rect rect, AnimationWindowHierarchyNode node, int row) { bool flag = false; 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, animationWindowCurve); if (currentValue is float) { float num = (float)currentValue; Rect dragHotZone = new Rect(rect.xMax - 75f - 15f, rect.y, 15f, rect.height); 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 (animationWindowCurve.valueType == typeof(bool)) { num = (float)((!GUI.Toggle(position, this.m_HierarchyItemValueControlIDs[row], num != 0f, GUIContent.none, EditorStyles.toggle)) ? 0 : 1); } else { int num2 = this.m_HierarchyItemValueControlIDs[row]; bool flag2 = GUIUtility.keyboardControl == num2 && EditorGUIUtility.editingTextField && Event.current.type == EventType.KeyDown && (Event.current.character == '\n' || Event.current.character == '\u0003'); if (EditorGUI.s_RecycledEditor.controlID == num2 && Event.current.type == EventType.MouseDown && position.Contains(Event.current.mousePosition)) { GUIUtility.keyboardControl = num2; } num = EditorGUI.DoFloatField(EditorGUI.s_RecycledEditor, position, dragHotZone, num2, num, EditorGUI.kFloatFieldFormatString, this.m_AnimationSelectionTextField, true); if (flag2) { GUI.changed = true; Event.current.Use(); } } if (float.IsInfinity(num) || float.IsNaN(num)) { num = 0f; } if (EditorGUI.EndChangeCheck()) { string undoLabel = "Edit Key"; AnimationKeyTime time = AnimationKeyTime.Time(this.state.currentTime, animationWindowCurve.clip.frameRate); AnimationWindowKeyframe animationWindowKeyframe = null; foreach (AnimationWindowKeyframe current in animationWindowCurve.m_Keyframes) { if (Mathf.Approximately(current.time, this.state.currentTime)) { animationWindowKeyframe = current; } } if (animationWindowKeyframe == null) { AnimationWindowUtility.AddKeyframeToCurve(animationWindowCurve, num, animationWindowCurve.valueType, time); } else { animationWindowKeyframe.value = num; } this.state.SaveCurve(animationWindowCurve, undoLabel); flag = true; } } } if (flag) { this.state.ResampleAnimation(); } }