static string PropertyName(EditorCurveBinding binding) { return(AnimationWindowUtility.GetPropertyDisplayName(binding.propertyName)); }
private void RemoveCurvesFromNodes(List <AnimationWindowHierarchyNode> nodes) { string undoLabel = "Remove Curve"; state.SaveKeySelection(undoLabel); foreach (var node in nodes) { AnimationWindowHierarchyNode hierarchyNode = (AnimationWindowHierarchyNode)node; if (hierarchyNode.parent is AnimationWindowHierarchyPropertyGroupNode && hierarchyNode.binding != null && AnimationWindowUtility.ForceGrouping((EditorCurveBinding)hierarchyNode.binding)) { hierarchyNode = (AnimationWindowHierarchyNode)hierarchyNode.parent; } if (hierarchyNode.curves == null) { continue; } List <AnimationWindowCurve> curves = null; // Property or propertygroup if (hierarchyNode is AnimationWindowHierarchyPropertyGroupNode || hierarchyNode is AnimationWindowHierarchyPropertyNode) { curves = AnimationWindowUtility.FilterCurves(hierarchyNode.curves.ToArray(), hierarchyNode.path, hierarchyNode.animatableObjectType, hierarchyNode.propertyName); } else { curves = AnimationWindowUtility.FilterCurves(hierarchyNode.curves.ToArray(), hierarchyNode.path, hierarchyNode.animatableObjectType); } foreach (AnimationWindowCurve animationWindowCurve in curves) { state.RemoveCurve(animationWindowCurve, undoLabel); } } m_TreeView.ReloadData(); state.controlInterface.ResampleAnimation(); }
private TreeViewItem AddGameObjectToHierarchy(GameObject gameObject, TreeViewItem parent) { string path = AnimationUtility.CalculateTransformPath(gameObject.transform, this.state.activeRootGameObject.transform); TreeViewItem parentNode = new AddCurvesPopupGameObjectNode(gameObject, parent, gameObject.name); List <TreeViewItem> visibleItems = new List <TreeViewItem>(); if (parent == null) { base.m_RootItem = parentNode; } EditorCurveBinding[] animatableBindings = AnimationUtility.GetAnimatableBindings(gameObject, this.state.activeRootGameObject); List <EditorCurveBinding> list2 = new List <EditorCurveBinding>(); for (int i = 0; i < animatableBindings.Length; i++) { EditorCurveBinding item = animatableBindings[i]; list2.Add(item); if (item.propertyName == "m_IsActive") { if (item.path != string.Empty) { TreeViewItem item2 = this.CreateNode(list2.ToArray(), parentNode); if (item2 != null) { visibleItems.Add(item2); } list2.Clear(); } else { list2.Clear(); } } else { bool flag = i == (animatableBindings.Length - 1); bool flag2 = false; if (!flag) { flag2 = animatableBindings[i + 1].type != item.type; } if (AnimationWindowUtility.IsCurveCreated(this.state.activeAnimationClip, item)) { list2.Remove(item); } if ((flag || flag2) && (list2.Count > 0)) { visibleItems.Add(this.AddAnimatableObjectToHierarchy(this.state.activeRootGameObject, list2.ToArray(), parentNode, path)); list2.Clear(); } } } if (showEntireHierarchy) { for (int j = 0; j < gameObject.transform.childCount; j++) { Transform child = gameObject.transform.GetChild(j); TreeViewItem item3 = this.AddGameObjectToHierarchy(child.gameObject, parentNode); if (item3 != null) { visibleItems.Add(item3); } } } TreeViewUtility.SetChildParentReferences(visibleItems, parentNode); return(parentNode); }
private void DoIconAndName(Rect rect, AnimationWindowHierarchyNode node, bool selected, bool focused, float indent) { EditorGUIUtility.SetIconSize(new Vector2(13, 13)); // If not set we see icons scaling down if text is being cropped // TODO: All this is horrible. SHAME FIX! if (Event.current.type == EventType.Repaint) { if (selected) { Styles.selectionStyle.Draw(rect, false, false, true, focused); } // Leave some space for the value field that comes after. if (node is AnimationWindowHierarchyPropertyNode) { rect.width -= k_ValueFieldOffsetFromRightSide + 2; } bool isLeftOverCurve = AnimationWindowUtility.IsNodeLeftOverCurve(node); bool isAmbiguous = AnimationWindowUtility.IsNodeAmbiguous(node); bool isPhantom = AnimationWindowUtility.IsNodePhantom(node); string warningText = ""; string tooltipText = ""; if (isPhantom) { warningText = " (Default Value)"; tooltipText = "Transform position, rotation and scale can't be partially animated. This value will be animated to the default value"; } if (isLeftOverCurve) { warningText = " (Missing!)"; tooltipText = "The GameObject or Component is missing (" + node.path + ")"; } if (isAmbiguous) { warningText = " (Duplicate GameObject name!)"; tooltipText = "Target for curve is ambiguous since there are multiple GameObjects with same name (" + node.path + ")"; } Color oldColor = m_AnimationLineStyle.normal.textColor; Color textColor = oldColor; if (node.depth == 0) { string nodePrefix = ""; if (node.curves.Length > 0) { AnimationWindowSelectionItem selectionBinding = node.curves[0].selectionBinding; string gameObjectName = GetGameObjectName(selectionBinding != null ? selectionBinding.rootGameObject : null, node.path); nodePrefix = string.IsNullOrEmpty(gameObjectName) ? "" : gameObjectName + " : "; } Styles.content = new GUIContent(nodePrefix + node.displayName + warningText, GetIconForItem(node), tooltipText); textColor = EditorGUIUtility.isProSkin ? Color.gray * 1.35f : Color.black; } else { Styles.content = new GUIContent(node.displayName + warningText, GetIconForItem(node), tooltipText); textColor = EditorGUIUtility.isProSkin ? Color.gray : m_LightSkinPropertyTextColor; var phantomColor = selected ? m_PhantomCurveColor * k_SelectedPhantomCurveColorMultiplier : m_PhantomCurveColor; textColor = isPhantom ? phantomColor : textColor; } textColor = isLeftOverCurve || isAmbiguous ? k_LeftoverCurveColor : textColor; SetStyleTextColor(m_AnimationLineStyle, textColor); rect.xMin += (int)(indent + Styles.foldoutWidth + m_AnimationLineStyle.margin.left); GUI.Label(rect, Styles.content, m_AnimationLineStyle); SetStyleTextColor(m_AnimationLineStyle, oldColor); } if (IsRenaming(node.id) && Event.current.type != EventType.Layout) { GetRenameOverlay().editFieldRect = new Rect(rect.x + k_IndentWidth, rect.y, rect.width - k_IndentWidth - 1, rect.height); } }
private GenericMenu GenerateMenu(List <AnimationWindowHierarchyNode> interactedNodes, bool enabled) { List <AnimationWindowCurve> curves = GetCurvesAffectedByNodes(interactedNodes, false); // Linked curves are like regular affected curves but always include transform siblings List <AnimationWindowCurve> linkedCurves = GetCurvesAffectedByNodes(interactedNodes, true); bool forceGroupRemove = curves.Count == 1 ? AnimationWindowUtility.ForceGrouping(curves[0].binding) : false; GenericMenu menu = new GenericMenu(); // Remove curves GUIContent removePropertyContent = new GUIContent(curves.Count > 1 || forceGroupRemove ? "Remove Properties" : "Remove Property"); if (!enabled) { menu.AddDisabledItem(removePropertyContent); } else { menu.AddItem(removePropertyContent, false, RemoveCurvesFromSelectedNodes); } // Change rotation interpolation bool showInterpolation = true; EditorCurveBinding[] curveBindings = new EditorCurveBinding[linkedCurves.Count]; for (int i = 0; i < linkedCurves.Count; i++) { curveBindings[i] = linkedCurves[i].binding; } RotationCurveInterpolation.Mode rotationInterpolation = GetRotationInterpolationMode(curveBindings); if (rotationInterpolation == RotationCurveInterpolation.Mode.Undefined) { showInterpolation = false; } else { foreach (var node in interactedNodes) { if (!(node is AnimationWindowHierarchyPropertyGroupNode)) { showInterpolation = false; } } } if (showInterpolation) { string legacyWarning = state.activeAnimationClip.legacy ? " (Not fully supported in Legacy)" : ""; GenericMenu.MenuFunction2 nullMenuFunction2 = null; menu.AddItem(EditorGUIUtility.TrTextContent("Interpolation/Euler Angles" + legacyWarning), rotationInterpolation == RotationCurveInterpolation.Mode.RawEuler, enabled ? ChangeRotationInterpolation : nullMenuFunction2, RotationCurveInterpolation.Mode.RawEuler); menu.AddItem(EditorGUIUtility.TrTextContent("Interpolation/Euler Angles (Quaternion)"), rotationInterpolation == RotationCurveInterpolation.Mode.Baked, enabled ? ChangeRotationInterpolation : nullMenuFunction2, RotationCurveInterpolation.Mode.Baked); menu.AddItem(EditorGUIUtility.TrTextContent("Interpolation/Quaternion"), rotationInterpolation == RotationCurveInterpolation.Mode.NonBaked, enabled ? ChangeRotationInterpolation : nullMenuFunction2, RotationCurveInterpolation.Mode.NonBaked); } // Menu items that are only applicaple when in animation mode: if (state.previewing) { menu.AddSeparator(""); bool allHaveKeys = true; bool noneHaveKeys = true; foreach (AnimationWindowCurve curve in curves) { bool curveHasKey = curve.HasKeyframe(state.time); if (!curveHasKey) { allHaveKeys = false; } else { noneHaveKeys = false; } } string str; str = "Add Key"; if (allHaveKeys || !enabled) { menu.AddDisabledItem(new GUIContent(str)); } else { menu.AddItem(new GUIContent(str), false, AddKeysAtCurrentTime, curves); } str = "Delete Key"; if (noneHaveKeys || !enabled) { menu.AddDisabledItem(new GUIContent(str)); } else { menu.AddItem(new GUIContent(str), false, DeleteKeysAtCurrentTime, curves); } } return(menu); }
private GenericMenu GenerateMenu(List <AnimationWindowHierarchyNode> interactedNodes) { List <AnimationWindowCurve> curvesAffectedByNodes = this.GetCurvesAffectedByNodes(interactedNodes, false); List <AnimationWindowCurve> curvesAffectedByNodes2 = this.GetCurvesAffectedByNodes(interactedNodes, true); bool flag = curvesAffectedByNodes.Count == 1 && AnimationWindowUtility.ForceGrouping(curvesAffectedByNodes[0].binding); GenericMenu genericMenu = new GenericMenu(); genericMenu.AddItem(new GUIContent((curvesAffectedByNodes.Count <= 1 && !flag) ? "Remove Property" : "Remove Properties"), false, new GenericMenu.MenuFunction(this.RemoveCurvesFromSelectedNodes)); bool flag2 = true; EditorCurveBinding[] array = new EditorCurveBinding[curvesAffectedByNodes2.Count]; for (int i = 0; i < curvesAffectedByNodes2.Count; i++) { array[i] = curvesAffectedByNodes2[i].binding; } RotationCurveInterpolation.Mode rotationInterpolationMode = this.GetRotationInterpolationMode(array); if (rotationInterpolationMode == RotationCurveInterpolation.Mode.Undefined) { flag2 = false; } else { foreach (AnimationWindowHierarchyNode current in interactedNodes) { if (!(current is AnimationWindowHierarchyPropertyGroupNode)) { flag2 = false; } } } if (flag2) { string str = (!this.state.activeAnimationClip.legacy) ? string.Empty : " (Not fully supported in Legacy)"; genericMenu.AddItem(new GUIContent("Interpolation/Euler Angles" + str), rotationInterpolationMode == RotationCurveInterpolation.Mode.RawEuler, new GenericMenu.MenuFunction2(this.ChangeRotationInterpolation), RotationCurveInterpolation.Mode.RawEuler); genericMenu.AddItem(new GUIContent("Interpolation/Euler Angles (Quaternion Approximation)"), rotationInterpolationMode == RotationCurveInterpolation.Mode.Baked, new GenericMenu.MenuFunction2(this.ChangeRotationInterpolation), RotationCurveInterpolation.Mode.Baked); genericMenu.AddItem(new GUIContent("Interpolation/Quaternion"), rotationInterpolationMode == RotationCurveInterpolation.Mode.NonBaked, new GenericMenu.MenuFunction2(this.ChangeRotationInterpolation), RotationCurveInterpolation.Mode.NonBaked); } if (AnimationMode.InAnimationMode()) { genericMenu.AddSeparator(string.Empty); bool flag3 = true; bool flag4 = true; bool flag5 = true; foreach (AnimationWindowCurve current2 in curvesAffectedByNodes) { if (!current2.HasKeyframe(this.state.time)) { flag3 = false; } else { flag4 = false; if (!current2.isPPtrCurve) { flag5 = false; } } } string text = "Add Key"; if (flag3) { genericMenu.AddDisabledItem(new GUIContent(text)); } else { genericMenu.AddItem(new GUIContent(text), false, new GenericMenu.MenuFunction2(this.AddKeysAtCurrentTime), curvesAffectedByNodes); } text = "Delete Key"; if (flag4) { genericMenu.AddDisabledItem(new GUIContent(text)); } else { genericMenu.AddItem(new GUIContent(text), false, new GenericMenu.MenuFunction2(this.DeleteKeysAtCurrentTime), curvesAffectedByNodes); } if (!flag5) { genericMenu.AddSeparator(string.Empty); List <KeyIdentifier> list = new List <KeyIdentifier>(); foreach (AnimationWindowCurve current3 in curvesAffectedByNodes) { if (!current3.isPPtrCurve) { int keyframeIndex = current3.GetKeyframeIndex(this.state.time); if (keyframeIndex != -1) { CurveRenderer curveRenderer = CurveRendererCache.GetCurveRenderer(this.state.activeAnimationClip, current3.binding); int curveID = CurveUtility.GetCurveID(this.state.activeAnimationClip, current3.binding); list.Add(new KeyIdentifier(curveRenderer, curveID, keyframeIndex)); } } } } } return(genericMenu); }
public AnimationWindowHierarchyPropertyNode(Type animatableObjectType, string propertyName, string path, TreeViewItem parent, EditorCurveBinding binding, bool isPptrNode) : base(AnimationWindowUtility.GetPropertyNodeID(path, animatableObjectType, propertyName), (parent == null) ? -1 : (parent.depth + 1), parent, animatableObjectType, propertyName, path, AnimationWindowUtility.GetNicePropertyDisplayName(animatableObjectType, propertyName)) { this.binding = new EditorCurveBinding?(binding); this.isPptrNode = isPptrNode; }
internal static bool IsRotationCurve(EditorCurveBinding curveBinding) { string propertyGroupName = AnimationWindowUtility.GetPropertyGroupName(curveBinding.propertyName); return(propertyGroupName == "m_LocalRotation" || propertyGroupName == "localEulerAnglesRaw"); }
public static bool IsRectTransformPosition(EditorCurveBinding curveBinding) { return(curveBinding.type == typeof(RectTransform) && AnimationWindowUtility.GetPropertyGroupName(curveBinding.propertyName) == "m_LocalPosition"); }
public void RemoveCurve(SerializedProperty property) { RemoveCurve(AnimationWindowUtility.SerializedPropertyToPropertyModifications(property)); }
public AnimationWindowHierarchyPropertyGroupNode(Type animatableObjectType, string propertyName, string path, TreeViewItem parent) : base(AnimationWindowUtility.GetPropertyNodeID(path, animatableObjectType, propertyName), (parent == null) ? -1 : (parent.depth + 1), parent, animatableObjectType, AnimationWindowUtility.GetPropertyGroupName(propertyName), path, AnimationWindowUtility.GetNicePropertyGroupDisplayName(animatableObjectType, propertyName)) { }
public void AddKey(SerializedProperty property) { AddKey(AnimationWindowUtility.SerializedPropertyToPropertyModifications(property)); }
private void RebuildGraph(Animator animator) { DestroyGraph(); m_Graph = PlayableGraph.Create("PreviewGraph"); m_Graph.SetTimeUpdateMode(DirectorUpdateMode.Manual); m_ClipPlayable = AnimationClipPlayable.Create(m_Graph, state.activeAnimationClip); m_ClipPlayable.SetOverrideLoopTime(true); m_ClipPlayable.SetLoopTime(false); m_ClipPlayable.SetApplyFootIK(false); m_CandidateClipPlayable = AnimationClipPlayable.Create(m_Graph, m_CandidateClip); m_CandidateClipPlayable.SetApplyFootIK(false); IAnimationWindowPreview[] previewComponents = FetchPostProcessComponents(); bool requiresDefaultPose = previewComponents != null && previewComponents.Length > 0; int nInputs = requiresDefaultPose ? 3 : 2; // Create a layer mixer if necessary, we'll connect playable nodes to it after having populated AnimationStream. AnimationLayerMixerPlayable mixer = AnimationLayerMixerPlayable.Create(m_Graph, nInputs); m_GraphRoot = (Playable)mixer; // Populate custom playable preview graph. if (previewComponents != null) { foreach (var component in previewComponents) { m_GraphRoot = component.BuildPreviewGraph(m_Graph, m_GraphRoot); } } // Finish hooking up mixer. int inputIndex = 0; if (requiresDefaultPose) { AnimationMode.RevertPropertyModificationsForGameObject(state.activeRootGameObject); EditorCurveBinding[] streamBindings = AnimationUtility.GetAnimationStreamBindings(state.activeRootGameObject); m_DefaultPose = new AnimationClip() { name = "DefaultPose" }; AnimationWindowUtility.CreateDefaultCurves(state, m_DefaultPose, streamBindings); m_DefaultPosePlayable = AnimationClipPlayable.Create(m_Graph, m_DefaultPose); m_DefaultPosePlayable.SetApplyFootIK(false); mixer.ConnectInput(inputIndex++, m_DefaultPosePlayable, 0, 1.0f); } mixer.ConnectInput(inputIndex++, m_ClipPlayable, 0, 1.0f); mixer.ConnectInput(inputIndex++, m_CandidateClipPlayable, 0, 1.0f); if (animator.applyRootMotion) { var motionX = AnimationMotionXToDeltaPlayable.Create(m_Graph); motionX.SetAbsoluteMotion(true); motionX.SetInputWeight(0, 1.0f); m_Graph.Connect(m_GraphRoot, 0, motionX, 0); m_GraphRoot = (Playable)motionX; } var output = AnimationPlayableOutput.Create(m_Graph, "ouput", animator); output.SetSourcePlayable(m_GraphRoot); output.SetWeight(0.0f); }
public void SaveCurve(AnimationWindowCurve curve) { Undo.RegisterCompleteObjectUndo(curve.clip, "Edit Candidate Curve"); AnimationWindowUtility.SaveCurve(curve.clip, curve); }
private void DoIconAndName(Rect rect, AnimationWindowHierarchyNode node, bool selected, bool focused, float indent) { EditorGUIUtility.SetIconSize(new Vector2(13f, 13f)); if (Event.current.type == EventType.Repaint) { if (selected) { TreeViewGUI.s_Styles.selectionStyle.Draw(rect, false, false, true, focused); } if (AnimationMode.InAnimationMode()) { rect.width -= 77f; } bool flag = AnimationWindowUtility.IsNodeLeftOverCurve(node, this.state.activeRootGameObject); bool flag2 = AnimationWindowUtility.IsNodeAmbiguous(node, this.state.activeRootGameObject); string text = string.Empty; string tooltip = string.Empty; if (flag) { text = " (Missing!)"; tooltip = "The GameObject or Component is missing (" + node.path + ")"; } if (flag2) { text = " (Duplicate GameObject name!)"; tooltip = "Target for curve is ambiguous since there are multiple GameObjects with same name (" + node.path + ")"; } if (node.depth == 0) { if (this.state.activeRootGameObject != null) { Transform x = this.state.activeRootGameObject.transform.Find(node.path); if (x == null) { flag = true; } } TreeViewGUI.s_Styles.content = new GUIContent(this.GetGameObjectName(node.path) + " : " + node.displayName + text, this.GetIconForNode(node), tooltip); Color textColor = this.m_AnimationLineStyle.normal.textColor; Color color = (!EditorGUIUtility.isProSkin) ? Color.black : (Color.gray * 1.35f); color = ((!flag && !flag2) ? color : AnimationWindowHierarchyGUI.k_LeftoverCurveColor); this.SetStyleTextColor(this.m_AnimationLineStyle, color); rect.xMin += (float)((int)(indent + this.k_FoldoutWidth)); GUI.Label(rect, TreeViewGUI.s_Styles.content, this.m_AnimationLineStyle); this.SetStyleTextColor(this.m_AnimationLineStyle, textColor); } else { TreeViewGUI.s_Styles.content = new GUIContent(node.displayName + text, this.GetIconForNode(node), tooltip); Color textColor2 = this.m_AnimationLineStyle.normal.textColor; Color color2 = (!EditorGUIUtility.isProSkin) ? this.m_LightSkinPropertyTextColor : Color.gray; color2 = ((!flag && !flag2) ? color2 : AnimationWindowHierarchyGUI.k_LeftoverCurveColor); this.SetStyleTextColor(this.m_AnimationLineStyle, color2); rect.xMin += (float)((int)(indent + this.k_IndentWidth + this.k_FoldoutWidth)); GUI.Label(rect, TreeViewGUI.s_Styles.content, this.m_AnimationLineStyle); this.SetStyleTextColor(this.m_AnimationLineStyle, textColor2); } } if (this.IsRenaming(node.id) && Event.current.type != EventType.Layout) { base.GetRenameOverlay().editFieldRect = new Rect(rect.x + this.k_IndentWidth, rect.y, rect.width - this.k_IndentWidth - 1f, rect.height); } }
public static List <AnimationWindowCurve> FilterCurves(AnimationWindowCurve[] curves, string path, Type animatableObjectType, string propertyName) { List <AnimationWindowCurve> list = new List <AnimationWindowCurve>(); if (curves != null) { 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); }
private void DoValueField(Rect rect, AnimationWindowHierarchyNode node, int row) { bool flag = 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 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'); 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; } } } EditorGUI.EndDisabledGroup(); if (flag) { this.state.ResampleAnimation(); } }
public static string GetNicePropertyGroupDisplayName(Type animatableObjectType, string propertyGroupName) { if (AnimationWindowUtility.ShouldPrefixWithTypeName(animatableObjectType, propertyGroupName)) { return(ObjectNames.NicifyVariableName(animatableObjectType.Name) + "." + AnimationWindowUtility.NicifyPropertyGroupName(animatableObjectType, propertyGroupName)); } return(AnimationWindowUtility.NicifyPropertyGroupName(animatableObjectType, propertyGroupName)); }
private void FillInMissingTransformCurves(List <AnimationWindowCurve> transformCurves, ref List <AnimationWindowCurve> curvesCache) { EditorCurveBinding lastBinding = transformCurves[0].binding; EditorCurveBinding?[] array = new EditorCurveBinding?[3]; foreach (AnimationWindowCurve current in transformCurves) { EditorCurveBinding binding = current.binding; if (binding.path != lastBinding.path || AnimationWindowUtility.GetPropertyGroupName(binding.propertyName) != AnimationWindowUtility.GetPropertyGroupName(lastBinding.propertyName)) { string propertyGroupName = AnimationWindowUtility.GetPropertyGroupName(lastBinding.propertyName); this.FillPropertyGroup(ref array, lastBinding, propertyGroupName, ref curvesCache); lastBinding = binding; array = new EditorCurveBinding?[3]; } this.AssignBindingToRightSlot(binding, ref array); } this.FillPropertyGroup(ref array, lastBinding, AnimationWindowUtility.GetPropertyGroupName(lastBinding.propertyName), ref curvesCache); }
public static bool ShouldShowAnimationWindowCurve(EditorCurveBinding curveBinding) { return(!AnimationWindowUtility.IsTransformType(curveBinding.type) || !curveBinding.propertyName.EndsWith(".w")); }
private TreeViewItem AddAnimatableObjectToHierarchy(GameObject root, EditorCurveBinding[] curveBindings, TreeViewItem parentNode, string path) { TreeViewItem treeViewItem = new AddCurvesPopupObjectNode(parentNode, path, AddCurvesPopupHierarchyDataSource.GetClassName(root, curveBindings[0])); treeViewItem.icon = AssetPreview.GetMiniThumbnail(AnimationUtility.GetAnimatedObject(root, curveBindings[0])); List <TreeViewItem> list = new List <TreeViewItem>(); List <EditorCurveBinding> list2 = new List <EditorCurveBinding>(); for (int i = 0; i < curveBindings.Length; i++) { EditorCurveBinding item = curveBindings[i]; list2.Add(item); if (i == curveBindings.Length - 1 || AnimationWindowUtility.GetPropertyGroupName(curveBindings[i + 1].propertyName) != AnimationWindowUtility.GetPropertyGroupName(item.propertyName)) { TreeViewItem treeViewItem2 = this.CreateNode(list2.ToArray(), treeViewItem); if (treeViewItem2 != null) { list.Add(treeViewItem2); } list2.Clear(); } } list.Sort(); TreeViewUtility.SetChildParentReferences(list, treeViewItem); return(treeViewItem); }
public static bool AddClipToAnimationComponent(Animation animation, AnimationClip newClip) { AnimationWindowUtility.SetClipAsLegacy(newClip); animation.AddClip(newClip, newClip.name); return(true); }
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, undoLabel); curvesChanged = true; } } } if (curvesChanged) { state.ResampleAnimation(); } }
public int CompareTo(AnimationWindowCurve obj) { bool flag = this.path.Equals(obj.path); bool flag2 = obj.type == this.type; int result; if (!flag && this.depth != obj.depth) { int num = Math.Min(this.path.Length, obj.path.Length); int startIndex = 0; int i; for (i = 0; i < num; i++) { if (this.path[i] != obj.path[i]) { break; } if (this.path[i] == '/') { startIndex = i + 1; } } if (i == num) { startIndex = num; } string text = this.path.Substring(startIndex); string text2 = obj.path.Substring(startIndex); if (string.IsNullOrEmpty(text)) { result = -1; } else if (string.IsNullOrEmpty(text2)) { result = 1; } else { Regex regex = new Regex("^[^\\/]*\\/"); Match match = regex.Match(text); string text3 = (!match.Success) ? text : match.Value.Substring(0, match.Value.Length - 1); Match match2 = regex.Match(text2); string strB = (!match2.Success) ? text2 : match2.Value.Substring(0, match2.Value.Length - 1); result = text3.CompareTo(strB); } } else { bool flag3 = this.type == typeof(Transform) && obj.type == typeof(Transform) && flag; bool flag4 = (this.type == typeof(Transform) || obj.type == typeof(Transform)) && flag; if (flag3) { string nicePropertyGroupDisplayName = AnimationWindowUtility.GetNicePropertyGroupDisplayName(typeof(Transform), AnimationWindowUtility.GetPropertyGroupName(this.propertyName)); string nicePropertyGroupDisplayName2 = AnimationWindowUtility.GetNicePropertyGroupDisplayName(typeof(Transform), AnimationWindowUtility.GetPropertyGroupName(obj.propertyName)); if (nicePropertyGroupDisplayName.Contains("Position") && nicePropertyGroupDisplayName2.Contains("Rotation")) { result = -1; return(result); } if (nicePropertyGroupDisplayName.Contains("Rotation") && nicePropertyGroupDisplayName2.Contains("Position")) { result = 1; return(result); } } else if (flag4) { if (this.type == typeof(Transform)) { result = -1; return(result); } result = 1; return(result); } if (flag && flag2) { int componentIndex = AnimationWindowUtility.GetComponentIndex(obj.propertyName); int componentIndex2 = AnimationWindowUtility.GetComponentIndex(this.propertyName); if (componentIndex != -1 && componentIndex2 != -1 && this.propertyName.Substring(0, this.propertyName.Length - 2) == obj.propertyName.Substring(0, obj.propertyName.Length - 2)) { result = componentIndex2 - componentIndex; return(result); } } result = (this.path + this.type + this.propertyName).CompareTo(obj.path + obj.type + obj.propertyName); } return(result); }
private void DeleteKeysAtCurrentTime(List <AnimationWindowCurve> curves) { AnimationWindowUtility.RemoveKeyframes(state, curves.ToArray(), state.time); }
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 TreeViewItem AddAnimatableObjectToHierarchy(GameObject root, EditorCurveBinding[] curveBindings, TreeViewItem parentNode, string path) { TreeViewItem item = new AddCurvesPopupObjectNode(parentNode, path, GetClassName(root, curveBindings[0])) { icon = AssetPreview.GetMiniThumbnail(AnimationUtility.GetAnimatedObject(root, curveBindings[0])) }; List <TreeViewItem> visibleItems = new List <TreeViewItem>(); List <EditorCurveBinding> list2 = new List <EditorCurveBinding>(); for (int i = 0; i < curveBindings.Length; i++) { EditorCurveBinding binding = curveBindings[i]; list2.Add(binding); if ((i == (curveBindings.Length - 1)) || (AnimationWindowUtility.GetPropertyGroupName(curveBindings[i + 1].propertyName) != AnimationWindowUtility.GetPropertyGroupName(binding.propertyName))) { TreeViewItem item2 = this.CreateNode(list2.ToArray(), item); if (item2 != null) { visibleItems.Add(item2); } list2.Clear(); } } visibleItems.Sort(); TreeViewUtility.SetChildParentReferences(visibleItems, item); return(item); }
private void AddKeysAtCurrentTime(List <AnimationWindowCurve> curves) { AnimationWindowUtility.AddKeyframes(state, curves, state.time); }
public AddCurvesPopupPropertyNode(TreeViewItem parent, EditorCurveBinding[] curveBindings) : base(curveBindings[0].GetHashCode(), parent.depth + 1, parent, AnimationWindowUtility.NicifyPropertyGroupName(curveBindings[0].type, AnimationWindowUtility.GetPropertyGroupName(curveBindings[0].propertyName))) { this.curveBindings = curveBindings; }
public static string GetNicePropertyDisplayName(Type animatableObjectType, string propertyName) { string result; if (AnimationWindowUtility.ShouldPrefixWithTypeName(animatableObjectType, propertyName)) { result = ObjectNames.NicifyVariableName(animatableObjectType.Name) + "." + AnimationWindowUtility.GetPropertyDisplayName(propertyName); } else { result = AnimationWindowUtility.GetPropertyDisplayName(propertyName); } return(result); }