private void SaveChangedCurvesFromCurveEditor() { Undo.RegisterCompleteObjectUndo(this.m_State.activeAnimationClip, "Edit Curve"); CurveWrapper[] animationCurves = this.m_CurveEditor.animationCurves; CurveWrapper curveWrapper; for (int i = 0; i < animationCurves.Length; i++) { curveWrapper = animationCurves[i]; if (curveWrapper.changed) { if (!curveWrapper.animationIsEditable) { Debug.LogError("Curve is not editable and shouldn't be saved."); } AnimationWindowCurve animationWindowCurve = this.m_State.allCurves.Find((AnimationWindowCurve curve) => curveWrapper.id == curve.GetCurveID()); if (animationWindowCurve != null) { AnimationUtility.SetEditorCurve(animationWindowCurve.clip, curveWrapper.binding, curveWrapper.curve); } curveWrapper.changed = false; } } this.m_State.ResampleAnimation(); }
public static object GetCurrentValue(AnimationWindowState state, AnimationWindowCurve curve) { if (AnimationMode.InAnimationMode() && (curve.rootGameObject != null)) { return AnimationWindowUtility.GetCurrentValue(curve.rootGameObject, curve.binding); } return curve.Evaluate(state.currentTime - curve.timeOffset); }
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 keyframe = AddKeyframeToCurve(curve, currentValue, editorCurveValueType, time); state.SaveCurve(curve); return keyframe; }
public AnimationWindowKeyframe(AnimationWindowCurve curve, Keyframe key) { this.time = key.time; this.value = key.value; this.curve = curve; this.m_InTangent = key.inTangent; this.m_OutTangent = key.outTangent; this.m_TangentMode = key.tangentMode; }
private AnimationWindowHierarchyPropertyNode AddPropertyToHierarchy(AnimationWindowCurve curve, AnimationWindowHierarchyNode parentNode) { AnimationWindowHierarchyPropertyNode node = new AnimationWindowHierarchyPropertyNode(curve.type, curve.propertyName, curve.path, parentNode, curve.binding, curve.isPPtrCurve); if (parentNode.icon != null) { node.icon = parentNode.icon; } else { node.icon = this.GetIcon(curve.binding); } node.indent = curve.depth; node.curves = new AnimationWindowCurve[] { curve }; return node; }
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; }
private AnimationWindowHierarchyPropertyGroupNode AddPropertyGroupToHierarchy(AnimationWindowCurve[] curves, AnimationWindowHierarchyNode parentNode) { List<AnimationWindowHierarchyNode> windowHierarchyNodeList = new List<AnimationWindowHierarchyNode>(); AnimationWindowHierarchyPropertyGroupNode propertyGroupNode = new AnimationWindowHierarchyPropertyGroupNode(curves[0].type, AnimationWindowUtility.GetPropertyGroupName(curves[0].propertyName), curves[0].path, (TreeViewItem) parentNode); propertyGroupNode.icon = this.GetIcon(curves[0].binding); propertyGroupNode.indent = curves[0].depth; propertyGroupNode.curves = curves; foreach (AnimationWindowCurve curve in curves) { AnimationWindowHierarchyPropertyNode hierarchy = this.AddPropertyToHierarchy(curve, (AnimationWindowHierarchyNode) propertyGroupNode); hierarchy.displayName = AnimationWindowUtility.GetPropertyDisplayName(hierarchy.propertyName); windowHierarchyNodeList.Add((AnimationWindowHierarchyNode) hierarchy); } TreeViewUtility.SetChildParentReferences(new List<TreeViewItem>((IEnumerable<TreeViewItem>) windowHierarchyNodeList.ToArray()), (TreeViewItem) propertyGroupNode); return propertyGroupNode; }
public static AnimationWindowKeyframe AddKeyframeToCurve(AnimationWindowCurve curve, object value, System.Type type, AnimationKeyTime time) { AnimationWindowKeyframe keyframe = curve.FindKeyAtTime(time); if (keyframe != null) { keyframe.value = value; return keyframe; } AnimationWindowKeyframe key = new AnimationWindowKeyframe { time = time.time }; if (curve.isPPtrCurve) { key.value = value; key.curve = curve; curve.AddKeyframe(key, time); return key; } if ((type == typeof(bool)) || (type == typeof(float))) { AnimationCurve curve2 = curve.ToAnimationCurve(); Keyframe keyframe3 = new Keyframe(time.time, (float) value); if (type == typeof(bool)) { CurveUtility.SetKeyTangentMode(ref keyframe3, 0, TangentMode.Stepped); CurveUtility.SetKeyTangentMode(ref keyframe3, 1, TangentMode.Stepped); CurveUtility.SetKeyBroken(ref keyframe3, true); key.m_TangentMode = keyframe3.tangentMode; key.m_InTangent = float.PositiveInfinity; key.m_OutTangent = float.PositiveInfinity; } else { int keyIndex = curve2.AddKey(keyframe3); if (keyIndex != -1) { CurveUtility.SetKeyModeFromContext(curve2, keyIndex); Keyframe keyframe4 = curve2[keyIndex]; key.m_TangentMode = keyframe4.tangentMode; } } key.value = value; key.curve = curve; curve.AddKeyframe(key, time); } return key; }
private AnimationWindowHierarchyPropertyGroupNode AddPropertyGroupToHierarchy(AnimationWindowCurve[] curves, AnimationWindowHierarchyNode parentNode) { List<AnimationWindowHierarchyNode> list = new List<AnimationWindowHierarchyNode>(); AnimationWindowHierarchyPropertyGroupNode node = new AnimationWindowHierarchyPropertyGroupNode(curves[0].type, AnimationWindowUtility.GetPropertyGroupName(curves[0].propertyName), curves[0].path, parentNode) { icon = this.GetIcon(curves[0].binding), indent = curves[0].depth, curves = curves }; foreach (AnimationWindowCurve curve in curves) { AnimationWindowHierarchyPropertyNode item = this.AddPropertyToHierarchy(curve, node); item.displayName = AnimationWindowUtility.GetPropertyDisplayName(item.propertyName); list.Add(item); } TreeViewUtility.SetChildParentReferences(new List<TreeViewItem>(list.ToArray()), node); return node; }
private AnimationWindowHierarchyPropertyGroupNode AddPropertyGroupToHierarchy(AnimationWindowCurve[] curves, AnimationWindowHierarchyNode parentNode) { List<AnimationWindowHierarchyNode> list = new List<AnimationWindowHierarchyNode>(); Type type = curves[0].type; AnimationWindowHierarchyPropertyGroupNode animationWindowHierarchyPropertyGroupNode = new AnimationWindowHierarchyPropertyGroupNode(type, AnimationWindowUtility.GetPropertyGroupName(curves[0].propertyName), curves[0].path, parentNode); animationWindowHierarchyPropertyGroupNode.icon = this.GetIcon(curves[0].binding); animationWindowHierarchyPropertyGroupNode.indent = curves[0].depth; animationWindowHierarchyPropertyGroupNode.curves = curves; for (int i = 0; i < curves.Length; i++) { AnimationWindowCurve curve = curves[i]; AnimationWindowHierarchyPropertyNode animationWindowHierarchyPropertyNode = this.AddPropertyToHierarchy(curve, animationWindowHierarchyPropertyGroupNode); animationWindowHierarchyPropertyNode.displayName = AnimationWindowUtility.GetPropertyDisplayName(animationWindowHierarchyPropertyNode.propertyName); list.Add(animationWindowHierarchyPropertyNode); } TreeViewUtility.SetChildParentReferences(new List<TreeViewItem>(list.ToArray()), animationWindowHierarchyPropertyGroupNode); return animationWindowHierarchyPropertyGroupNode; }
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[] bindingArray = RotationCurveInterpolation.RemapAnimationBindingForRotationAddKey(binding, activeAnimationClip); for (int i = 0; i < 3; i++) { AnimationWindowCurve curve = new AnimationWindowCurve(activeAnimationClip, bindingArray[i], type); if ((curve.length == 0) && (state.frame != 0)) { AnimationWindowUtility.AddKeyframeToCurve(curve, previousEulerAngles[i], type, AnimationKeyTime.Frame(0, activeAnimationClip.frameRate)); } AnimationWindowUtility.AddKeyframeToCurve(curve, currentEulerAngles[i], type, AnimationKeyTime.Frame(state.frame, activeAnimationClip.frameRate)); state.SaveCurve(curve); } } }
private static void AddKey(AnimationWindowState state, EditorCurveBinding binding, System.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); }
public static List<AnimationWindowCurve> FilterCurves(AnimationWindowCurve[] curves, string path, Type animatableObjectType) { List<AnimationWindowCurve> list = new List<AnimationWindowCurve>(); for (int i = 0; i < curves.Length; i++) { AnimationWindowCurve animationWindowCurve = curves[i]; if (animationWindowCurve.path.Equals(path) && animationWindowCurve.type == animatableObjectType) { list.Add(animationWindowCurve); } } return list; }
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; }
public AnimationWindowKeyframe(AnimationWindowCurve curve, ObjectReferenceKeyframe key) { this.time = key.time; this.value = key.value; this.curve = curve; }
public static float GetNextKeyframeTime(AnimationWindowCurve[] curves, float currentTime, float frameRate) { float num = 3.40282347E+38f; float val = currentTime + 1f / frameRate; bool flag = false; for (int i = 0; i < curves.Length; i++) { AnimationWindowCurve animationWindowCurve = curves[i]; foreach (AnimationWindowKeyframe current in animationWindowCurve.m_Keyframes) { if (current.time < num && current.time > currentTime) { num = Math.Max(current.time, val); flag = true; } } } return (!flag) ? currentTime : num; }
public static float GetPreviousKeyframeTime(AnimationWindowCurve[] curves, float currentTime, float frameRate) { float num = -3.40282347E+38f; float b = Mathf.Max(0f, currentTime - 1f / frameRate); bool flag = false; for (int i = 0; i < curves.Length; i++) { AnimationWindowCurve animationWindowCurve = curves[i]; foreach (AnimationWindowKeyframe current in animationWindowCurve.m_Keyframes) { if (current.time > num && current.time < currentTime) { num = Mathf.Min(current.time, b); flag = true; } } } return (!flag) ? currentTime : num; }
public static bool CurveExists(EditorCurveBinding binding, AnimationWindowCurve[] curves) { for (int i = 0; i < curves.Length; i++) { AnimationWindowCurve animationWindowCurve = curves[i]; if (binding.propertyName == animationWindowCurve.binding.propertyName && binding.type == animationWindowCurve.binding.type && binding.path == animationWindowCurve.binding.path) { return true; } } return false; }
public static void RenameCurvePath(AnimationWindowCurve curve, EditorCurveBinding newBinding, AnimationClip clip) { AnimationUtility.SetEditorCurve(clip, curve.binding, null); AnimationUtility.SetEditorCurve(clip, newBinding, curve.ToAnimationCurve()); }
public static List<AnimationWindowCurve> FilterCurves(AnimationWindowCurve[] curves, string path, System.Type animatableObjectType, string propertyName) { List<AnimationWindowCurve> list = new List<AnimationWindowCurve>(); string propertyGroupName = GetPropertyGroupName(propertyName); bool flag = propertyGroupName == propertyName; foreach (AnimationWindowCurve curve in curves) { bool flag2 = !flag ? curve.propertyName.Equals(propertyName) : GetPropertyGroupName(curve.propertyName).Equals(propertyGroupName); if ((curve.path.Equals(path) && (curve.type == animatableObjectType)) && flag2) { list.Add(curve); } } return list; }
public static List<AnimationWindowCurve> FilterCurves(AnimationWindowCurve[] curves, string path, Type animatableObjectType, string propertyName) { List<AnimationWindowCurve> list = new List<AnimationWindowCurve>(); string propertyGroupName = AnimationWindowUtility.GetPropertyGroupName(propertyName); bool flag = propertyGroupName == propertyName; for (int i = 0; i < curves.Length; i++) { AnimationWindowCurve animationWindowCurve = curves[i]; bool flag2 = (!flag) ? animationWindowCurve.propertyName.Equals(propertyName) : AnimationWindowUtility.GetPropertyGroupName(animationWindowCurve.propertyName).Equals(propertyGroupName); if (animationWindowCurve.path.Equals(path) && animationWindowCurve.type == animatableObjectType && flag2) { list.Add(animationWindowCurve); } } return list; }
public static List<AnimationWindowCurve> FilterCurves(AnimationWindowCurve[] curves, string path, bool entireHierarchy) { List<AnimationWindowCurve> list = new List<AnimationWindowCurve>(); for (int i = 0; i < curves.Length; i++) { AnimationWindowCurve animationWindowCurve = curves[i]; if (animationWindowCurve.path.Equals(path) || (entireHierarchy && animationWindowCurve.path.Contains(path))) { list.Add(animationWindowCurve); } } return list; }
public void SaveCurve(AnimationWindowCurve curve) { Undo.RegisterCompleteObjectUndo(activeAnimationClip, "Edit Curve"); AnimationWindowUtility.SaveCurve(activeAnimationClip, curve); }
public static List<AnimationWindowCurve> FilterCurves(AnimationWindowCurve[] curves, string path, bool entireHierarchy) { List<AnimationWindowCurve> list = new List<AnimationWindowCurve>(); foreach (AnimationWindowCurve curve in curves) { if (curve.path.Equals(path) || (entireHierarchy && curve.path.Contains(path))) { list.Add(curve); } } return list; }
private void PeformDragAndDrop(AnimationWindowCurve targetCurve, float time) { if (DragAndDrop.objectReferences.Length == 0 || targetCurve == null) return; this.state.ClearSelections(); foreach (UnityEngine.Object dropObjectReference in this.GetSortedDragAndDropObjectReferences()) { UnityEngine.Object @object = dropObjectReference; if (@object is Texture2D) @object = (UnityEngine.Object) SpriteUtility.TextureToSprite(dropObjectReference as Texture2D); this.CreateNewPPtrKeyframe(time, @object, targetCurve); time += 1f / this.state.activeAnimationClip.frameRate; } this.state.SaveCurve(targetCurve); DragAndDrop.AcceptDrag(); }
public static float GetPreviousKeyframeTime(AnimationWindowCurve[] curves, float currentTime, float frameRate) { float minValue = float.MinValue; float b = Mathf.Max((float) 0f, (float) (currentTime - (1f / frameRate))); bool flag = false; foreach (AnimationWindowCurve curve in curves) { foreach (AnimationWindowKeyframe keyframe in curve.m_Keyframes) { if ((keyframe.time > minValue) && (keyframe.time < currentTime)) { minValue = Mathf.Min(keyframe.time, b); flag = true; } } } return (!flag ? currentTime : minValue); }
public static float GetNextKeyframeTime(AnimationWindowCurve[] curves, float currentTime, float frameRate) { float maxValue = float.MaxValue; float num2 = currentTime + (1f / frameRate); bool flag = false; foreach (AnimationWindowCurve curve in curves) { foreach (AnimationWindowKeyframe keyframe in curve.m_Keyframes) { if ((keyframe.time < maxValue) && (keyframe.time > currentTime)) { maxValue = Math.Max(keyframe.time, num2); flag = true; } } } return (!flag ? currentTime : maxValue); }
public static CurveWrapper GetCurveWrapper(AnimationWindowCurve curve, AnimationClip clip) { return new CurveWrapper { renderer = new NormalCurveRenderer(curve.ToAnimationCurve()), binding = curve.binding, id = CurveUtility.GetCurveID(clip, curve.binding), color = CurveUtility.GetPropertyColor(curve.propertyName), hidden = false }; }
private void DoSpriteDropAfterGeneratingNewDopeline(EditorCurveBinding? spriteBinding) { if (DragAndDrop.objectReferences.Length == 1) Analytics.Event("Sprite Drag and Drop", "Drop single sprite into empty dopesheet", "null", 1); else Analytics.Event("Sprite Drag and Drop", "Drop multiple sprites into empty dopesheet", "null", 1); AnimationWindowCurve animationWindowCurve = new AnimationWindowCurve(this.state.activeAnimationClip, spriteBinding.Value, typeof (Sprite)); this.state.SaveCurve(animationWindowCurve); this.PeformDragAndDrop(animationWindowCurve, 0.0f); }
public static List<AnimationWindowCurve> FilterCurves(AnimationWindowCurve[] curves, string path, System.Type animatableObjectType) { List<AnimationWindowCurve> list = new List<AnimationWindowCurve>(); foreach (AnimationWindowCurve curve in curves) { if (curve.path.Equals(path) && (curve.type == animatableObjectType)) { list.Add(curve); } } return list; }
private void CreateNewPPtrKeyframe(float time, UnityEngine.Object value, AnimationWindowCurve targetCurve) { AnimationWindowKeyframe animationWindowKeyframe = new AnimationWindowKeyframe(targetCurve, new ObjectReferenceKeyframe() { time = time, value = value }); AnimationKeyTime keyTime = AnimationKeyTime.Time(animationWindowKeyframe.time, this.state.frameRate); targetCurve.AddKeyframe(animationWindowKeyframe, keyTime); this.state.SelectKey(animationWindowKeyframe); }
public static AnimationWindowKeyframe AddKeyframeToCurve(AnimationWindowCurve curve, object value, Type type, AnimationKeyTime time) { AnimationWindowKeyframe animationWindowKeyframe = curve.FindKeyAtTime(time); if (animationWindowKeyframe != null) { animationWindowKeyframe.value = value; return animationWindowKeyframe; } AnimationWindowKeyframe animationWindowKeyframe2 = new AnimationWindowKeyframe(); animationWindowKeyframe2.time = time.time; if (curve.isPPtrCurve) { animationWindowKeyframe2.value = value; animationWindowKeyframe2.curve = curve; curve.AddKeyframe(animationWindowKeyframe2, time); } else { if (type == typeof(bool) || type == typeof(float)) { AnimationCurve animationCurve = curve.ToAnimationCurve(); Keyframe key = new Keyframe(time.time, (float)value); if (type == typeof(bool)) { CurveUtility.SetKeyTangentMode(ref key, 0, TangentMode.Stepped); CurveUtility.SetKeyTangentMode(ref key, 1, TangentMode.Stepped); CurveUtility.SetKeyBroken(ref key, true); animationWindowKeyframe2.m_TangentMode = key.tangentMode; animationWindowKeyframe2.m_InTangent = float.PositiveInfinity; animationWindowKeyframe2.m_OutTangent = float.PositiveInfinity; } else { int num = animationCurve.AddKey(key); if (num != -1) { CurveUtility.SetKeyModeFromContext(animationCurve, num); animationWindowKeyframe2.m_TangentMode = animationCurve[num].tangentMode; } } animationWindowKeyframe2.value = value; animationWindowKeyframe2.curve = curve; curve.AddKeyframe(animationWindowKeyframe2, time); } } return animationWindowKeyframe2; }