public void ProcessDelete(IUSHierarchyItem item) { var timelineContainerItem = item as USTimelineContainerHierarchyItem; var timelineHierarchyItem = item as IUSTimelineHierarchyItem; if (timelineContainerItem) { foreach (var child in timelineContainerItem.Children.ToList()) { ProcessDelete(child); } USUndoManager.RegisterCompleteObjectUndo(this, "Remove Timeline Container"); USUndoManager.RegisterCompleteObjectUndo(USHierarchy, "Remove Timeline Container"); USHierarchy.RootItems.Remove(timelineContainerItem); var gameObjectToDestroy = timelineContainerItem.TimelineContainer.gameObject; USUndoManager.DestroyImmediate(timelineContainerItem); USUndoManager.DestroyImmediate(gameObjectToDestroy); } else if (timelineHierarchyItem) { var parent = USHierarchy.GetParentOf(timelineHierarchyItem); timelineHierarchyItem.RestoreBaseState(); USUndoManager.RegisterCompleteObjectUndo(parent, "Remove Timeline"); parent.RemoveChild(timelineHierarchyItem); var gameObjectToDestroy = timelineHierarchyItem.TimelineToDestroy().gameObject; USUndoManager.DestroyImmediate(timelineHierarchyItem); USUndoManager.DestroyImmediate(gameObjectToDestroy); } }
public void ProcessDraggingObjects(Vector2 mouseDelta, bool snap, float snapValue) { if (!ObjectPathTimeline) { return; } USUndoManager.PropertyChange(ObjectPathTimeline, "Drag Selection"); USUndoManager.PropertyChange(this, "Drag Selection"); foreach (var selectedObject in SelectedObjects) { var keyframe = selectedObject as SplineKeyframe; Vector3 newPosition = SourcePositions[keyframe] + mouseDelta; newPosition.x = newPosition.x + XScroll - DisplayArea.x; if (snap) { newPosition.x = Mathf.Round(newPosition.x / snapValue) * snapValue; } var newTime = ((newPosition.x / DisplayArea.width) * Duration) / XScale; newTime = Mathf.Clamp(newTime, 0.0f, Duration); if (ObjectPathTimeline.ObjectSpline.Nodes[0] == keyframe) { ObjectPathTimeline.StartTime = newTime; } if (ObjectPathTimeline.ObjectSpline.Nodes[ObjectPathTimeline.ObjectSpline.Nodes.Count - 1] == keyframe) { ObjectPathTimeline.EndTime = newTime; } } ObjectPathTimeline.Process(ObjectPathTimeline.Sequence.RunningTime, ObjectPathTimeline.Sequence.PlaybackRate); }
private void SetCamera(USObserverKeyframe keyframe, float time, Shared.TypeOfTransition transitionType, float transitionDuration, Camera camera) { if (AnimationHelper.IsInAnimationMode) { ObserverTimeline.StopTimeline(); ObserverTimeline.StartTimeline(); } if (keyframe != null) { USUndoManager.PropertyChange(keyframe, "Set Camera"); keyframe.KeyframeCamera = camera; } else { USUndoManager.RegisterCompleteObjectUndo(this, "Set Camera"); var newKeyframe = CreateInstance <USObserverKeyframe>(); newKeyframe.FireTime = time; newKeyframe.KeyframeCamera = camera; newKeyframe.TransitionType = transitionType; newKeyframe.TransitionDuration = transitionDuration; USUndoManager.RegisterCreatedObjectUndo(newKeyframe, "Set Camera"); USUndoManager.RegisterCompleteObjectUndo(ObserverTimeline, "Set Camera"); ObserverTimeline.AddKeyframe(newKeyframe); var cachedData = CreateInstance <ObserverRenderData>(); cachedData.Keyframe = newKeyframe; cachedObserverRenderData.Add(cachedData); } ObserverTimeline.Process(ObserverTimeline.Sequence.RunningTime, ObserverTimeline.Sequence.PlaybackRate); }
private void RemoveAnimationTrack() { USUndoManager.RegisterCompleteObjectUndo(AnimationTimeline, "Remove Track"); AnimationTimeline.RemoveTrack(AnimationTrack); AnimationTimelineHierarchy.RemoveAnimationTrack(AnimationTrack); }
private void ProcessDuplicate(IUSHierarchyItem item) { var timelineContainer = item as USTimelineContainerHierarchyItem; if (timelineContainer != null) { var newTimelineContainer = USEditor.DuplicateTimelineContainer(timelineContainer.TimelineContainer, CurrentSequence); USUndoManager.RegisterCreatedObjectUndo(newTimelineContainer.gameObject, "Duplicate Timeline"); AddNewTimelineContainer(newTimelineContainer); } var timeline = item as IUSTimelineHierarchyItem; if (timeline != null) { USUndoManager.RegisterCompleteObjectUndo(this, "Duplicate Timeline"); USUndoManager.RegisterCompleteObjectUndo(USHierarchy, "Duplicate Timeline"); var newTimeline = USEditor.DuplicateTimeline(timeline.BaseTimeline, timeline.BaseTimeline.TimelineContainer); USUndoManager.RegisterCreatedObjectUndo(newTimeline.gameObject, "Duplicate Timeline"); var parent = USHierarchy.GetParentOf(item) as USTimelineContainerHierarchyItem; USUndoManager.RegisterCompleteObjectUndo(parent, "Duplicate Timeline"); parent.AddTimeline(newTimeline); } }
private void StartProcessingAnimationMode() { if (AnimationHelper.IsInAnimationMode) { return; } if (Application.isPlaying) { return; } var objects = new List <Component>(); // All observered objects foreach (var observedObject in CurrentSequence.ObservedObjects) { SaveObjectValueInAnimationMode(observedObject, ref objects); } USUndoManager.RegisterCompleteObjectUndo(this, "Play"); IsInAnimationMode = true; ContentRenderer.StoreBaseState(); }
private void RemoveProperty() { USUndoManager.RegisterCompleteObjectUndo(PropertyTimeline, "Remove Curve"); USUndoManager.RegisterCompleteObjectUndo(this, "Remove Curve"); foreach (var child in Children) { USUndoManager.RegisterCompleteObjectUndo(child, "Remove Curve"); } var preFix = PropertyFieldInfo.Name; var propertyInfo = PropertyTimeline.GetProperty(preFix, PropertyFieldInfo.Component); foreach (var child in Children) { ((USPropertyMemberHierarchyItem)child).Curve = null; } propertyInfo.RestoreBaseState(); PropertyTimeline.RemoveProperty(propertyInfo); USUndoManager.DestroyImmediate(propertyInfo); IsSelected = false; foreach (var child in Children) { ((USPropertyMemberHierarchyItem)child).IsSelected = false; } }
private void FloatingOnGUI() { GUILayout.Box("", FloatingBackground, GUILayout.MaxWidth(FloatingWidth), GUILayout.Height(17.0f)); if (Event.current.type == EventType.Repaint) { FloatingBackgroundRect = GUILayoutUtility.GetLastRect(); } bool wasLabelPressed; var newExpandedState = USEditor.FoldoutLabel(FloatingBackgroundRect, IsExpanded, USEditorUtility.GetReadableTimelineContainerName(TimelineContainer), out wasLabelPressed); if (newExpandedState != IsExpanded) { USUndoManager.PropertyChange(this, "Foldout"); IsExpanded = newExpandedState; } base.FloatingOnGUI(0); if (!USRuntimeUtility.HasObserverTimeline(TimelineContainer.transform) && TimelineContainer.AffectedObject == null) { IsExpanded = false; } }
protected override void FloatingOnGUI(int depth) { GUILayout.Box("", FloatingBackground, GUILayout.MaxWidth(FloatingWidth), GUILayout.Height(17.0f)); if (Event.current.type == EventType.Repaint) { var lastRect = GUILayoutUtility.GetLastRect(); lastRect.x += GetXOffsetForDepth(depth); lastRect.width -= GetXOffsetForDepth(depth); if (FloatingBackgroundRect != lastRect) { EditorWindow.Repaint(); FloatingBackgroundRect = lastRect; } } var wasLabelPressed = false; var newExpandedState = USEditor.FoldoutLabel(FloatingBackgroundRect, IsExpanded, AnimationTimeline.name, out wasLabelPressed); if (newExpandedState != IsExpanded) { USUndoManager.PropertyChange(this, "Foldout"); IsExpanded = newExpandedState; EditorWindow.Repaint(); } base.FloatingOnGUI(depth); }
protected override void FloatingOnGUI(int depth) { GUILayout.Box("", FloatingBackground, GUILayout.Width(FloatingWidth), GUILayout.Height(17.0f)); if (Event.current.type == EventType.Repaint) { var lastRect = GUILayoutUtility.GetLastRect(); lastRect.x += GetXOffsetForDepth(depth); lastRect.width -= GetXOffsetForDepth(depth); FloatingBackgroundRect = lastRect; } if (Component == null) { var missingRect = FloatingBackgroundRect; missingRect.x += GetXOffsetForDepth(2); GUI.Label(missingRect, "*Missing*"); IsExpanded = false; return; } var wasLabelPressed = false; var displayableContent = new GUIContent(Component.GetType().Name, EditorGUIUtility.ObjectContent(Component, Component.GetType()).image); var newExpandedState = USEditor.FoldoutLabel(FloatingBackgroundRect, IsExpanded, displayableContent, out wasLabelPressed); if (newExpandedState != IsExpanded) { USUndoManager.PropertyChange(this, "Foldout"); IsExpanded = newExpandedState; } }
public void ProcessDraggingObjects(Vector2 mouseDelta, bool snap, float snapValue) { if (!ObserverTimeline) { return; } USUndoManager.PropertyChange(this, "Drag Selection"); foreach (var selectedObject in SelectedObjects) { var keyframe = selectedObject as USObserverKeyframe; USUndoManager.PropertyChange(keyframe, "Drag Selection"); Vector3 newPosition = SourcePositions[keyframe] + mouseDelta; newPosition.x = newPosition.x + XScroll - DisplayArea.x; if (snap) { newPosition.x = Mathf.Round(newPosition.x / snapValue) * snapValue; } var newTime = ((newPosition.x / DisplayArea.width) * Duration) / XScale; newTime = Mathf.Clamp(newTime, 0.0f, Duration); keyframe.FireTime = newTime; } if (AnimationHelper.IsInAnimationMode) { ObserverTimeline.Process(ObserverTimeline.Sequence.RunningTime, ObserverTimeline.Sequence.PlaybackRate); } }
public override void DoGUI(int depth) { using (new Shared.GUIBeginHorizontal()) { FloatingOnGUI(depth); EventEditor.Duration = EventTimeline.Sequence.Duration; EventEditor.XScale = XScale; EventEditor.XScroll = XScroll; EventEditor.YScroll = YScroll; if (IsExpanded) { EventEditor.OnGUI(); } else { EventEditor.OnCollapsedGUI(); } GUI.Box(FloatingBackgroundRect, "", FloatingBackground); var wasLabelPressed = false; var newExpandedState = USEditor.FoldoutLabel(FloatingBackgroundRect, IsExpanded, EventTimeline.name, out wasLabelPressed); if (newExpandedState != IsExpanded) { USUndoManager.PropertyChange(this, "Foldout"); IsExpanded = newExpandedState; EditorWindow.Repaint(); } base.FloatingOnGUI(depth, MoreRect); } }
public void AddAnimationTrack(string layer) { var track = CreateInstance <AnimationTrack>(); USUndoManager.RegisterCreatedObjectUndo(track, "Add New Track"); track.Layer = MecanimAnimationUtility.LayerNameToIndex(AnimationTimeline.AffectedObject.gameObject, layer); USUndoManager.RegisterCompleteObjectUndo(AnimationTimeline, "Add New Track"); AnimationTimeline.AddTrack(track); var hierarchyItem = CreateInstance(typeof(USAnimationTimelineTrackHierarchyItem)) as USAnimationTimelineTrackHierarchyItem; USUndoManager.RegisterCreatedObjectUndo(hierarchyItem, "Add New Track"); hierarchyItem.AnimationTrack = track; hierarchyItem.AnimationTimelineHierarchy = this; hierarchyItem.AnimationTimeline = AnimationTimeline; hierarchyItem.Initialize(AnimationTimeline); USUndoManager.RegisterCompleteObjectUndo(USHierarchy, "Add New Track"); USHierarchy.RootItems.Add(hierarchyItem as IUSHierarchyItem); if (AnimationTimeline.AnimationTracks.Count == 1) { IsExpanded = true; } }
private void AddNewState(float time, string stateName) { var clipData = CreateInstance <AnimationClipData>(); clipData.TargetObject = AnimationTimeline.AffectedObject.gameObject; clipData.StartTime = time; clipData.StateName = stateName; clipData.StateDuration = MecanimAnimationUtility.GetStateDuration(stateName, clipData.TargetObject); clipData.PlaybackDuration = MecanimAnimationUtility.GetStateDuration(stateName, clipData.TargetObject); clipData.Track = AnimationTrack; USUndoManager.RegisterCreatedObjectUndo(clipData, "Add New Clip"); var cachedData = CreateInstance <AnimationClipRenderData>(); cachedData.animationClipData = clipData; USUndoManager.RegisterCreatedObjectUndo(clipData, "Add New Clip"); USUndoManager.RegisterCompleteObjectUndo(AnimationTrack, "Add New Clip"); AnimationTrack.AddClip(clipData); USUndoManager.RegisterCompleteObjectUndo(this, "Add New Clip"); cachedClipRenderData.Add(cachedData); OnSelectedObjects(new List <UnityEngine.Object>() { clipData }); }
public override void Initialize(USTimelineBase timeline) { base.Initialize(timeline); USUndoManager.RegisterCompleteObjectUndo(EventEditor, "Add New Timeline"); EventEditor.InitializeWithEvents(EventTimeline.Events); EventEditor.EventTimeline = EventTimeline; }
public void HideAll() { USUndoManager.RegisterCompleteObjectUndo(this, "Hide All"); for (var i = 0; i < RootItems.Count; i++) { RootItems[i].HideAll(); } }
public static void DuplicateSequence(USSequencer currentSequence) { var duplicateObject = Object.Instantiate(currentSequence.gameObject) as GameObject; USDetachScriptableObjects.ProcessSequence(duplicateObject.GetComponent <USSequencer>()); Selection.activeGameObject = duplicateObject; USUndoManager.RegisterCreatedObjectUndo(duplicateObject, "Duplicate Sequence"); }
public void AddKeyframeAtTimeUsingCurrentValue(USPropertyInfo propertyInfo, float time) { USUndoManager.RegisterCompleteObjectUndo(propertyInfo, "Add Keyframe"); propertyInfo.AddKeyframe(time, AutoTangentMode); USUndoManager.RegisterCompleteObjectUndo(this, "Add Keyframe"); RebuildCurvesOnNextGUI = true; AreCurvesDirty = true; EditorWindow.Repaint(); }
public virtual void HideAll() { USUndoManager.RegisterCompleteObjectUndo(this, "Hide All"); IsExpanded = false; foreach (var child in Children) { child.HideAll(); } }
public virtual void Expand() { USUndoManager.RegisterCompleteObjectUndo(this, "Expand All"); IsExpanded = true; foreach (var child in Children) { child.Expand(); } }
public void RemoveAnimationTrack(AnimationTrack track) { USUndoManager.RegisterCompleteObjectUndo(AnimationTimeline, "Add New Track"); AnimationTimeline.RemoveTrack(track); USUndoManager.RegisterCompleteObjectUndo(USHierarchy, "Add New Track"); USHierarchy.RootItems.Remove(USHierarchy.RootItems.Where(item => ((USAnimationTimelineTrackHierarchyItem)item).AnimationTrack == track).First()); USUndoManager.DestroyImmediate(track); }
private void SequenceSwitch(USSequencer nextSequence) { USUndoManager.RegisterCompleteObjectUndo(this, "Select new sequence"); CurrentSequence = nextSequence; USUndoManager.RegisterCompleteObjectUndo(ContentRenderer, "Select new sequence"); ContentRenderer.OnSequenceChange(CurrentSequence); TryToFixPropertyTimelines(CurrentSequence); TryToFixObserverTimelines(CurrentSequence); }
public void DeleteSelection() { USUndoManager.RegisterCompleteObjectUndo(this, "RemoveClip"); foreach (var selectedObject in SelectedObjects) { RemoveClip(selectedObject as AnimationClipData); } SelectedObjects.Clear(); }
public void ResetSelection() { if (SelectedObjects.Count > 0) { USUndoManager.PropertyChange(this, "Select None"); USEditorUtility.RemoveFromUnitySelection(SelectedObjects); SelectedObjects.Clear(); SourcePositions.Clear(); } }
public void OnDeSelectedObjects(List <UnityEngine.Object> selectedObjects) { USUndoManager.PropertyChange(this, "DeSelect"); foreach (var selectedObject in selectedObjects) { SelectedObjects.Remove(selectedObject); var selection = Selection.objects != null?Selection.objects.ToList() : new List <UnityEngine.Object>(); selection.Remove(selectedObject); Selection.objects = selection.ToArray(); } }
public void SetRunningTime(float newRunningTime) { StartProcessingAnimationMode(); if (!CurrentSequence.IsPlaying) { CurrentSequence.Play(); } CurrentSequence.Pause(); USUndoManager.PropertyChange(CurrentSequence, "Set Running Time"); CurrentSequence.RunningTime = newRunningTime; }
public void AddNewTimelineContainer(USTimelineContainer timelineContainer) { var newHierarchyItem = CreateInstance(typeof(USTimelineContainerHierarchyItem)) as USTimelineContainerHierarchyItem; USUndoManager.RegisterCreatedObjectUndo(newHierarchyItem, "Add New Timeline Container"); USUndoManager.RegisterCompleteObjectUndo(newHierarchyItem, "Add New Timeline Container"); newHierarchyItem.SetupWithTimelineContainer(timelineContainer); USUndoManager.RegisterCompleteObjectUndo(USHierarchy, "Add New Timeline Container"); USHierarchy.AddHierarchyItemToRoot(newHierarchyItem as IUSHierarchyItem); }
public override void DoGUI(int depth) { GUILayout.Box("", FloatingBackground, GUILayout.Width(FloatingWidth), GUILayout.Height(17.0f)); if (Event.current.type == EventType.Repaint) { IsSelected = Children.Any(element => ((USPropertyMemberHierarchyItem)element).IsSelected); var lastRect = GUILayoutUtility.GetLastRect(); lastRect.x += GetXOffsetForDepth(depth); lastRect.width -= GetXOffsetForDepth(depth); FloatingBackgroundRect = lastRect; } if (IsSelected) { GUI.Box(new Rect(0, FloatingBackgroundRect.y, FloatingBackgroundRect.width + FloatingBackgroundRect.x, FloatingBackgroundRect.height), ""); } var newExpandedState = IsExpanded; bool wasLabelPressed; newExpandedState = USEditor.FoldoutLabel(FloatingBackgroundRect, IsExpanded, PropertyFieldInfo.ReadableName, out wasLabelPressed); if (newExpandedState != IsExpanded) { USUndoManager.PropertyChange(this, "Foldout"); IsExpanded = newExpandedState; } var addRect = FloatingBackgroundRect; var padding = 1.0f; var addWidth = 22.0f; addRect.x = addRect.x + addRect.width - addWidth - padding; addRect.width = addWidth; if (!HasChildCurves) { if (GUI.Button(addRect, "+")) { AddProperty(); } } else { using (new Shared.GUIChangeColor(Color.red)) { if (GUI.Button(addRect, "-")) { RemoveProperty(); } } } }
public void DuplicateSelection() { USUndoManager.RegisterCompleteObjectUndo(this, "Duplicate"); foreach (var selectedObject in SelectedObjects) { var keyframe = selectedObject as USInternalKeyframe; var newKeyframe = Instantiate(keyframe) as USInternalKeyframe; newKeyframe.name = keyframe.name; AddKeyframe(newKeyframe, newKeyframe.curve); USUndoManager.RegisterCreatedObjectUndo(newKeyframe, "Duplicate"); } }
private void RemoveKeyframeAtIndex(int index) { if (index >= ObjectPathTimeline.Keyframes.Count || index < 0) { return; } var keyframe = ObjectPathTimeline.Keyframes[index]; ObjectPathTimeline.RemoveKeyframe(keyframe); GUI.changed = true; USUndoManager.DestroyImmediate(keyframe); }