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); }
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); } }
private void RemoveKeyframe(USObserverKeyframe keyframe) { USUndoManager.RegisterCompleteObjectUndo(this, "Remove Keyframe"); var data = cachedObserverRenderData.Where(element => element.Keyframe == keyframe).First(); cachedObserverRenderData.Remove(data); USUndoManager.PropertyChange(ObserverTimeline, "Remove Keyframe"); ObserverTimeline.RemoveKeyframe(keyframe); ObserverTimeline.Process(ObserverTimeline.Sequence.RunningTime, ObserverTimeline.Sequence.PlaybackRate); USUndoManager.DestroyImmediate(data); USUndoManager.DestroyImmediate(keyframe); }