public void SetBoth(TangentMode mode, List <KeyIdentifier> keysToSet) { List <ChangedCurve> changedCurves = new List <ChangedCurve>(); foreach (KeyIdentifier keyToSet in keysToSet) { AnimationCurve animationCurve = keyToSet.curve; Keyframe key = keyToSet.keyframe; AnimationUtility.SetKeyBroken(ref key, false); AnimationUtility.SetKeyRightTangentMode(ref key, mode); AnimationUtility.SetKeyLeftTangentMode(ref key, mode); // Smooth Tangents based on neighboring nodes // Note: not needed since the UpdateTangentsFromModeSurrounding call below will handle it //if (mode == TangentMode.ClampedAuto) animationCurve.SmoothTangents(keyToSet.key, 0.0F); // Smooth tangents based on existing tangents if (mode == TangentMode.Free) { float slope = CurveUtility.CalculateSmoothTangent(key); key.inTangent = slope; key.outTangent = slope; } animationCurve.MoveKey(keyToSet.key, key); AnimationUtility.UpdateTangentsFromModeSurrounding(animationCurve, keyToSet.key); ChangedCurve changedCurve = new ChangedCurve(animationCurve, keyToSet.curveId, keyToSet.binding); if (!changedCurves.Contains(changedCurve)) { changedCurves.Add(changedCurve); } } updater.UpdateCurves(changedCurves, "Set Tangents"); }
public void SetBoth(AnimationUtility.TangentMode mode, List <KeyIdentifier> keysToSet) { List <ChangedCurve> list = new List <ChangedCurve>(); foreach (KeyIdentifier current in keysToSet) { AnimationCurve curve = current.curve; Keyframe keyframe = current.keyframe; AnimationUtility.SetKeyBroken(ref keyframe, false); AnimationUtility.SetKeyRightTangentMode(ref keyframe, mode); AnimationUtility.SetKeyLeftTangentMode(ref keyframe, mode); if (mode == AnimationUtility.TangentMode.Free) { float num = CurveUtility.CalculateSmoothTangent(keyframe); keyframe.inTangent = num; keyframe.outTangent = num; } curve.MoveKey(current.key, keyframe); AnimationUtility.UpdateTangentsFromModeSurrounding(curve, current.key); ChangedCurve item = new ChangedCurve(curve, current.curveId, current.binding); if (!list.Contains(item)) { list.Add(item); } } this.updater.UpdateCurves(list, "Set Tangents"); }
public void Flatten(List <KeyIdentifier> keysToSet) { List <ChangedCurve> curve1 = new List <ChangedCurve>(); List <int> curveIds = new List <int>(); using (List <KeyIdentifier> .Enumerator enumerator = keysToSet.GetEnumerator()) { while (enumerator.MoveNext()) { KeyIdentifier current = enumerator.Current; AnimationCurve curve2 = current.curve; Keyframe keyframe = current.keyframe; keyframe.inTangent = 0.0f; keyframe.outTangent = 0.0f; curve2.MoveKey(current.key, keyframe); CurveUtility.UpdateTangentsFromModeSurrounding(curve2, current.key); ChangedCurve changedCurve = new ChangedCurve(curve2, current.binding); if (!curve1.Contains(changedCurve)) { curve1.Add(changedCurve); } curveIds.Add(current.curveId); } } if (this.updater is DopeSheetEditor) { this.updater.UpdateCurves(curve1, "Set Tangents"); } else { this.updater.UpdateCurves(curveIds, "Set Tangents"); } }
public void OnGUI() { if (this.state.selection.canChangeAnimationClip) { string[] clipMenuContent = this.GetClipMenuContent(); EditorGUI.BeginChangeCheck(); this.selectedIndex = EditorGUILayout.Popup(this.ClipToIndex(this.state.activeAnimationClip), clipMenuContent, EditorStyles.toolbarPopup, new GUILayoutOption[0]); if (EditorGUI.EndChangeCheck()) { if (clipMenuContent[this.selectedIndex] == AnimationWindowStyles.createNewClip.text) { AnimationClip animationClip = AnimationWindowUtility.CreateNewClip(this.state.selection.rootGameObject.name); if (animationClip) { AnimationWindowUtility.AddClipToAnimationPlayerComponent(this.state.activeAnimationPlayer, animationClip); this.state.activeAnimationClip = animationClip; } GUIUtility.ExitGUI(); } else { this.state.activeAnimationClip = this.IndexToClip(this.selectedIndex); } } } else if (this.state.activeAnimationClip != null) { Rect controlRect = EditorGUILayout.GetControlRect(false, EditorGUIUtility.singleLineHeight, AnimationWindowStyles.toolbarLabel, new GUILayoutOption[0]); EditorGUI.LabelField(controlRect, CurveUtility.GetClipName(this.state.activeAnimationClip), AnimationWindowStyles.toolbarLabel); } }
public void Flatten(List <KeyIdentifier> keysToSet) { List <ChangedCurve> list = new List <ChangedCurve>(); List <int> list2 = new List <int>(); foreach (KeyIdentifier current in keysToSet) { AnimationCurve curve = current.curve; Keyframe keyframe = current.keyframe; keyframe.inTangent = 0f; keyframe.outTangent = 0f; curve.MoveKey(current.key, keyframe); CurveUtility.UpdateTangentsFromModeSurrounding(curve, current.key); ChangedCurve item = new ChangedCurve(curve, current.binding); if (!list.Contains(item)) { list.Add(item); } list2.Add(current.curveId); } if (this.updater is DopeSheetEditor) { this.updater.UpdateCurves(list, "Set Tangents"); } else { this.updater.UpdateCurves(list2, "Set Tangents"); } }
public void OnGUI() { if (state.selection.canChangeAnimationClip) { string[] menuContent = GetClipMenuContent(); EditorGUI.BeginChangeCheck(); // TODO: Make this more robust selectedIndex = EditorGUILayout.Popup(ClipToIndex(state.activeAnimationClip), menuContent, EditorStyles.toolbarPopup); if (EditorGUI.EndChangeCheck()) { if (menuContent[selectedIndex] == AnimationWindowStyles.createNewClip.text) { AnimationClip newClip = AnimationWindowUtility.CreateNewClip(state.selection.rootGameObject.name); if (newClip) { AnimationWindowUtility.AddClipToAnimationPlayerComponent(state.activeAnimationPlayer, newClip); state.activeAnimationClip = newClip; } // Layout has changed, bail out now. EditorGUIUtility.ExitGUI(); } else { state.activeAnimationClip = IndexToClip(selectedIndex); } } } else if (state.activeAnimationClip != null) { Rect r = EditorGUILayout.GetControlRect(false, EditorGUIUtility.singleLineHeight, AnimationWindowStyles.toolbarLabel); EditorGUI.LabelField(r, CurveUtility.GetClipName(state.activeAnimationClip), AnimationWindowStyles.toolbarLabel); } }
public static void UpdateTangentsFromMode(AnimationCurve curve) { for (int index = 0; index < curve.length; ++index) { CurveUtility.UpdateTangentsFromMode(curve, index); } }
public void UpdateTangentsFromMode(int index, int componentIndex) { AnimationCurve curve = this.GetCurve(componentIndex); if ((index >= 0) && (index < curve.length)) { Keyframe key = curve[index]; if ((CurveUtility.GetKeyTangentMode(key, 0) == TangentMode.Linear) && (index >= 1)) { key.inTangent = this.CalculateLinearTangent(index, index - 1, componentIndex); curve.MoveKey(index, key); } if ((CurveUtility.GetKeyTangentMode(key, 1) == TangentMode.Linear) && ((index + 1) < curve.length)) { key.outTangent = this.CalculateLinearTangent(index, index + 1, componentIndex); curve.MoveKey(index, key); } if ((CurveUtility.GetKeyTangentMode(key, 0) == TangentMode.Smooth) || (CurveUtility.GetKeyTangentMode(key, 1) == TangentMode.Smooth)) { float num = this.CalculateSmoothTangent(index, componentIndex); key.outTangent = num; key.inTangent = num; curve.MoveKey(index, key); } } }
public static void UpdateTangentsFromMode(AnimationCurve curve) { for (int i = 0; i < curve.length; i++) { CurveUtility.UpdateTangentsFromMode(curve, i); } }
public static void UpdateTangentsFromMode(AnimationCurve curve, AnimationClip clip, EditorCurveBinding curveBinding) { if (RotationCurveInterpolation.GetModeFromCurveData(curveBinding) == RotationCurveInterpolation.Mode.NonBaked) { QuaternionCurveTangentCalculation quaternionCurveTangentCalculation = default(QuaternionCurveTangentCalculation); int curveIndexFromName = RotationCurveInterpolation.GetCurveIndexFromName(curveBinding.propertyName); for (int i = 0; i < 3; i++) { if (i == curveIndexFromName) { quaternionCurveTangentCalculation.SetCurve(i, curve); } else { EditorCurveBinding binding = curveBinding; binding.propertyName = "localEulerAngles." + RotationCurveInterpolation.kPostFix[i]; AnimationCurve editorCurve = AnimationUtility.GetEditorCurve(clip, binding); if (editorCurve == null) { return; } quaternionCurveTangentCalculation.SetCurve(i, editorCurve); } } quaternionCurveTangentCalculation.UpdateTangentsFromMode(curveIndexFromName); } else { CurveUtility.UpdateTangentsFromMode(curve); } }
public static void UpdateTangentsFromModeSurrounding(AnimationCurve curve, int index) { CurveUtility.UpdateTangentsFromMode(curve, index - 2); CurveUtility.UpdateTangentsFromMode(curve, index - 1); CurveUtility.UpdateTangentsFromMode(curve, index); CurveUtility.UpdateTangentsFromMode(curve, index + 1); CurveUtility.UpdateTangentsFromMode(curve, index + 2); }
internal static void SetSmoothEditable(ref Keyframe[] keys) { for (int i = 0; i < keys.Length; i++) { CurveUtility.SetKeyBroken(ref keys[i], false); CurveUtility.SetKeyTangentMode(ref keys[i], 0, TangentMode.Editable); CurveUtility.SetKeyTangentMode(ref keys[i], 1, TangentMode.Editable); } }
public static void SetKeyModeFromContext(AnimationCurve curve, int keyIndex) { Keyframe key = curve[keyIndex]; bool flag = false; bool flag2 = false; if (keyIndex > 0) { if (CurveUtility.GetKeyBroken(curve[keyIndex - 1])) { flag = true; } if (CurveUtility.GetKeyTangentMode(curve[keyIndex - 1], 1) == TangentMode.Smooth) { flag2 = true; } } if (keyIndex < curve.length - 1) { if (CurveUtility.GetKeyBroken(curve[keyIndex + 1])) { flag = true; } if (CurveUtility.GetKeyTangentMode(curve[keyIndex + 1], 0) == TangentMode.Smooth) { flag2 = true; } } CurveUtility.SetKeyBroken(ref key, flag); if (flag && !flag2) { if (keyIndex > 0) { CurveUtility.SetKeyTangentMode(ref key, 0, CurveUtility.GetKeyTangentMode(curve[keyIndex - 1], 1)); } if (keyIndex < curve.length - 1) { CurveUtility.SetKeyTangentMode(ref key, 1, CurveUtility.GetKeyTangentMode(curve[keyIndex + 1], 0)); } } else { TangentMode mode = TangentMode.Smooth; if (keyIndex > 0 && CurveUtility.GetKeyTangentMode(curve[keyIndex - 1], 1) != TangentMode.Smooth) { mode = TangentMode.Editable; } if (keyIndex < curve.length - 1 && CurveUtility.GetKeyTangentMode(curve[keyIndex + 1], 0) != TangentMode.Smooth) { mode = TangentMode.Editable; } CurveUtility.SetKeyTangentMode(ref key, 0, mode); CurveUtility.SetKeyTangentMode(ref key, 1, mode); } curve.MoveKey(keyIndex, key); }
private string[] GetClipNames() { AnimationClip[] orderedClipList = this.GetOrderedClipList(); string[] array = new string[orderedClipList.Length]; for (int i = 0; i < orderedClipList.Length; i++) { array[i] = CurveUtility.GetClipName(orderedClipList[i]); } return(array); }
internal static Keyframe[] GetLinearMirrorKeys() { Keyframe[] keyframeArray = new Keyframe[] { new Keyframe(0f, 1f, -1f, -1f), new Keyframe(1f, 0f, -1f, -1f) }; for (int i = 0; i < 2; i++) { CurveUtility.SetKeyBroken(ref keyframeArray[i], false); CurveUtility.SetKeyTangentMode(ref keyframeArray[i], 0, TangentMode.Smooth); CurveUtility.SetKeyTangentMode(ref keyframeArray[i], 1, TangentMode.Smooth); } return(keyframeArray); }
private string[] GetClipNames() { AnimationClip[] clips = GetOrderedClipList(); string[] clipNames = new string[clips.Length]; for (int i = 0; i < clips.Length; i++) { clipNames[i] = CurveUtility.GetClipName(clips[i]); } return(clipNames); }
private AnimationClip[] GetOrderedClipList() { AnimationClip[] clips = new AnimationClip[0]; if (state.activeRootGameObject != null) { clips = AnimationUtility.GetAnimationClips(state.activeRootGameObject); } Array.Sort(clips, (AnimationClip clip1, AnimationClip clip2) => CurveUtility.GetClipName(clip1).CompareTo(CurveUtility.GetClipName(clip2))); return(clips); }
public void SetTangent(int leftRight, TangentMode mode, List <KeyIdentifier> keysToSet) { List <int> curveIds = new List <int>(); List <ChangedCurve> curve1 = new List <ChangedCurve>(); using (List <KeyIdentifier> .Enumerator enumerator = keysToSet.GetEnumerator()) { while (enumerator.MoveNext()) { KeyIdentifier current = enumerator.Current; AnimationCurve curve2 = current.curve; Keyframe keyframe = current.keyframe; CurveUtility.SetKeyBroken(ref keyframe, true); if (leftRight == 2) { CurveUtility.SetKeyTangentMode(ref keyframe, 0, mode); CurveUtility.SetKeyTangentMode(ref keyframe, 1, mode); } else { CurveUtility.SetKeyTangentMode(ref keyframe, leftRight, mode); if (CurveUtility.GetKeyTangentMode(keyframe, 1 - leftRight) == TangentMode.Smooth) { CurveUtility.SetKeyTangentMode(ref keyframe, 1 - leftRight, TangentMode.Editable); } } if (mode == TangentMode.Stepped && (leftRight == 0 || leftRight == 2)) { keyframe.inTangent = float.PositiveInfinity; } if (mode == TangentMode.Stepped && (leftRight == 1 || leftRight == 2)) { keyframe.outTangent = float.PositiveInfinity; } curve2.MoveKey(current.key, keyframe); CurveUtility.UpdateTangentsFromModeSurrounding(curve2, current.key); ChangedCurve changedCurve = new ChangedCurve(curve2, current.binding); if (!curve1.Contains(changedCurve)) { curve1.Add(changedCurve); } curveIds.Add(current.curveId); } } if (this.updater is DopeSheetEditor) { this.updater.UpdateCurves(curve1, "Set Tangents"); } else { this.updater.UpdateCurves(curveIds, "Set Tangents"); } }
private string[] GetClipNames() { AnimationClip[] animationClips = new AnimationClip[0]; if ((this.state.activeRootGameObject != null) && (this.state.activeAnimationClip != null)) { animationClips = AnimationUtility.GetAnimationClips(this.state.activeRootGameObject); } string[] strArray = new string[animationClips.Length]; for (int i = 0; i < animationClips.Length; i++) { strArray[i] = CurveUtility.GetClipName(animationClips[i]); } return(strArray); }
public void RefreshAnimatedState(AnimationHierarchyData data, Transform tr) { this.m_Animated = false; string path = AnimationUtility.CalculateTransformPath(tr, data.animated.transform); foreach (int num in data.animatedPaths.Keys) { if (num == CurveUtility.GetPathAndTypeID(path, this.obj.GetType())) { this.m_Animated = true; break; } } }
private string[] GetClipNames() { AnimationClip[] array = new AnimationClip[0]; if (this.state.activeRootGameObject != null && this.state.activeAnimationClip != null) { array = AnimationUtility.GetAnimationClips(this.state.activeRootGameObject); } string[] array2 = new string[array.Length]; for (int i = 0; i < array.Length; i++) { array2[i] = CurveUtility.GetClipName(array[i]); } return(array2); }
public void SetTangent(int leftRight, TangentMode mode, List <KeyIdentifier> keysToSet) { List <int> list = new List <int>(); List <ChangedCurve> list2 = new List <ChangedCurve>(); foreach (KeyIdentifier current in keysToSet) { AnimationCurve curve = current.curve; Keyframe keyframe = current.keyframe; CurveUtility.SetKeyBroken(ref keyframe, true); if (leftRight == 2) { CurveUtility.SetKeyTangentMode(ref keyframe, 0, mode); CurveUtility.SetKeyTangentMode(ref keyframe, 1, mode); } else { CurveUtility.SetKeyTangentMode(ref keyframe, leftRight, mode); if (CurveUtility.GetKeyTangentMode(keyframe, 1 - leftRight) == TangentMode.Smooth) { CurveUtility.SetKeyTangentMode(ref keyframe, 1 - leftRight, TangentMode.Editable); } } if (mode == TangentMode.Stepped && (leftRight == 0 || leftRight == 2)) { keyframe.inTangent = float.PositiveInfinity; } if (mode == TangentMode.Stepped && (leftRight == 1 || leftRight == 2)) { keyframe.outTangent = float.PositiveInfinity; } curve.MoveKey(current.key, keyframe); CurveUtility.UpdateTangentsFromModeSurrounding(curve, current.key); ChangedCurve item = new ChangedCurve(curve, current.binding); if (!list2.Contains(item)) { list2.Add(item); } list.Add(current.curveId); } if (this.updater is DopeSheetEditor) { this.updater.UpdateCurves(list2, "Set Tangents"); } else { this.updater.UpdateCurves(list, "Set Tangents"); } }
internal static Keyframe[] GetLinearKeys() { Keyframe[] keyframeArray = new Keyframe[2] { new Keyframe(0.0f, 0.0f, 1f, 1f), new Keyframe(1f, 1f, 1f, 1f) }; for (int index = 0; index < 2; ++index) { CurveUtility.SetKeyBroken(ref keyframeArray[index], false); CurveUtility.SetKeyTangentMode(ref keyframeArray[index], 0, TangentMode.Smooth); CurveUtility.SetKeyTangentMode(ref keyframeArray[index], 1, TangentMode.Smooth); } return(keyframeArray); }
private void SetAnimationCurves() { this.m_AnimatedCurves = new Hashtable(); this.m_AnimatedPaths = new Hashtable(); this.m_LeftoverCurves = new Hashtable(); if (this.clip != null) { EditorCurveBinding[] curveBindings = AnimationUtility.GetCurveBindings(this.clip); EditorCurveBinding[] array = curveBindings; for (int i = 0; i < array.Length; i++) { EditorCurveBinding editorCurveBinding = array[i]; int curveID = CurveUtility.GetCurveID(this.clip, editorCurveBinding); this.m_AnimatedCurves[curveID] = true; if (!this.CheckIfPropertyExists(editorCurveBinding)) { this.m_LeftoverCurves[editorCurveBinding] = editorCurveBinding; } else { this.m_AnimatedPaths[CurveUtility.GetPathAndTypeID(editorCurveBinding.path, editorCurveBinding.type)] = true; string text = editorCurveBinding.path; while (true) { int hashCode = text.GetHashCode(); if (this.m_AnimatedPaths.Contains(hashCode)) { break; } this.m_AnimatedPaths[hashCode] = true; if (text.Length == 0) { break; } int num = text.LastIndexOf('/'); if (num > 0) { text = text.Substring(0, num); } else { text = string.Empty; } } } } } }
public void Flatten(List <KeyIdentifier> keysToSet) { List <int> list = new List <int>(); foreach (KeyIdentifier current in keysToSet) { AnimationCurve curve = current.curve; Keyframe keyframe = current.keyframe; keyframe.inTangent = 0f; keyframe.outTangent = 0f; curve.MoveKey(current.key, keyframe); CurveUtility.UpdateTangentsFromModeSurrounding(curve, current.key); list.Add(current.curveId); } this.updater.UpdateCurves(list, "Set Tangents"); }
public static void SetKeyTangentMode(ref Keyframe key, int leftRight, TangentMode mode) { if (leftRight == 0) { key.tangentMode &= -7; key.tangentMode |= (int)((int)mode << 1); } else { key.tangentMode &= -25; key.tangentMode |= (int)((int)mode << 3); } if (CurveUtility.GetKeyTangentMode(key, leftRight) != mode) { Debug.Log("bug"); } }
// (case 1029160) Modified version of EditorGUI.DoPopup to fit large data list query. private AnimationClip DoClipPopup(AnimationClip clip, GUIStyle style) { Rect position = EditorGUILayout.GetControlRect(false, EditorGUI.kSingleLineHeight, style); int controlID = GUIUtility.GetControlID(s_ClipPopupHash, FocusType.Keyboard, position); clip = ClipPopupCallbackInfo.GetSelectedClipForControl(controlID, clip); Event evt = Event.current; switch (evt.type) { case EventType.Repaint: Font originalFont = style.font; if (originalFont && EditorGUIUtility.GetBoldDefaultFont() && originalFont == EditorStyles.miniFont) { style.font = EditorStyles.miniBoldFont; } GUIContent buttonContent = EditorGUIUtility.TempContent(CurveUtility.GetClipName(clip)); buttonContent.tooltip = AssetDatabase.GetAssetPath(clip); style.Draw(position, buttonContent, controlID, false); style.font = originalFont; break; case EventType.MouseDown: if (evt.button == 0 && position.Contains(evt.mousePosition)) { DisplayClipMenu(position, controlID, clip); GUIUtility.keyboardControl = controlID; evt.Use(); } break; case EventType.KeyDown: if (evt.MainActionKeyForControl(controlID)) { DisplayClipMenu(position, controlID, clip); evt.Use(); } break; } return(clip); }
public static void SetKeyTangentMode(ref Keyframe key, int leftRight, TangentMode mode) { if (leftRight == 0) { key.tangentMode &= -7; key.tangentMode |= (int)mode << 1; } else { key.tangentMode &= -25; key.tangentMode |= (int)mode << 3; } if (CurveUtility.GetKeyTangentMode(key, leftRight) == mode) { return; } Debug.Log((object)"bug"); }
public string[] GetClipNames() { string[] array; if (this.hasAnimationComponent) { AnimationClip[] animationClips = AnimationUtility.GetAnimationClips(this.animatedObject); array = new string[animationClips.Length]; for (int i = 0; i < animationClips.Length; i++) { array[i] = CurveUtility.GetClipName(animationClips[i]); } } else { array = new string[0]; } return(array); }
public void RefreshCurves() { if (m_ClipDataSource == null || m_Selection == null) { return; } var bindings = new List <EditorCurveBinding>(); foreach (int s in m_Selection) { var item = (CurveTreeViewNode)m_TreeView.FindItem(s); if (item != null && item.bindings != null) { bindings.AddRange(item.bindings); } } AnimationClip clip = m_ClipDataSource.animationClip; var wrappers = new List <CurveWrapper>(); int curveWrapperId = 0; foreach (EditorCurveBinding b in bindings) { var wrapper = new CurveWrapper { id = curveWrapperId++, binding = b, groupId = -1, color = CurveUtility.GetPropertyColor(b.propertyName), hidden = false, readOnly = false, renderer = new NormalCurveRenderer(AnimationUtility.GetEditorCurve(clip, b)), getAxisUiScalarsCallback = GetAxisScalars }; wrapper.renderer.SetCustomRange(0.0f, clip.length); wrappers.Add(wrapper); } m_CurveEditor.animationCurves = wrappers.ToArray(); }