void DeleteTimeline() { UnityEngine.Object[] objsToSave = new UnityEngine.Object[] { SequenceEditor.GetSequence(), _timeline }; Undo.RegisterCompleteObjectUndo(objsToSave, string.Empty); Undo.SetTransformParent(_timeline.transform, null, string.Empty); SequenceEditor.GetSequence().Remove(_timeline); Undo.DestroyObjectImmediate(_timeline.gameObject); }
void ChangeOwner() { Undo.RecordObject(_timeline, "Change Timeline Owner"); _timeline.SetOwner(Selection.activeTransform); _timeline.name = Selection.activeTransform.name; if (!SequenceEditor.GetSequence().IsStopped) { _timeline.Init(); } }
void DuplicateTrack() { Undo.RecordObjects(new UnityEngine.Object[] { _timelineEditor, _track.GetTimeline() }, string.Empty); GameObject duplicateTrack = (GameObject)Instantiate(_track.gameObject); duplicateTrack.name = _track.gameObject.name; Undo.SetTransformParent(duplicateTrack.transform, _track.GetTimeline().transform, string.Empty); Undo.RegisterCreatedObjectUndo(duplicateTrack, "duplicate Track"); if (!SequenceEditor.GetSequence().IsStopped) { duplicateTrack.GetComponent <FTrack>().Init(); } }
void DuplicateTimeline() { UnityEngine.Object[] objsToSave = new UnityEngine.Object[] { SequenceEditor, SequenceEditor.GetSequence() }; Undo.RecordObjects(objsToSave, string.Empty); GameObject duplicateTimeline = (GameObject)Instantiate(_timeline.gameObject); duplicateTimeline.name = _timeline.gameObject.name; Undo.SetTransformParent(duplicateTimeline.transform, _timeline.Sequence.TimelineContainer, string.Empty); Undo.RegisterCreatedObjectUndo(duplicateTimeline, "duplicate Timeline"); if (!SequenceEditor.GetSequence().IsStopped) { duplicateTimeline.GetComponent <FTimeline>().Init(); } }
void AddTimeline() { Undo.IncrementCurrentGroup(); UnityEngine.Object[] objsToSave = new UnityEngine.Object[] { SequenceEditor, SequenceEditor.GetSequence() }; Undo.RecordObjects(objsToSave, string.Empty); GameObject timelineGO = new GameObject("TimeLine"); FTimeline timeline = timelineGO.AddComponent <Flux.FTimeline>(); //timeline.SetOwner(((GameObject)obj).transform); SequenceEditor.GetSequence().Add(timeline); Undo.RegisterCompleteObjectUndo(objsToSave, string.Empty); Undo.RegisterCreatedObjectUndo(timeline.gameObject, "create Timeline"); Undo.CollapseUndoOperations(Undo.GetCurrentGroup()); }
public virtual void Render(int id, Rect rect, int headerWidth, FrameRange viewRange, float pixelsPerFrame) { rect.y += _offsetAnim.value.y; _rect = rect; Rect viewRect = rect; viewRect.y += _offsetAnim.value.y; viewRect.xMax = headerWidth; viewRect.xMin = viewRect.xMax - 16; viewRect.height = 16; if (_track.CanTogglePreview()) { if (Event.current.type == EventType.MouseDown) { if (viewRect.Contains(Event.current.mousePosition)) { if (Event.current.button == 0) // left click? { _track.IsPreviewing = !_track.IsPreviewing; FUtility.RepaintGameView(); Event.current.Use(); } } } } Rect trackHeaderRect = rect; trackHeaderRect.xMax = headerWidth; bool selected = _isSelected; if (selected) { Color c = FGUI.GetSelectionColor(); GUI.color = c; GUI.DrawTexture(trackHeaderRect, EditorGUIUtility.whiteTexture); GUI.color = FGUI.GetTextColor(); // Debug.Log( GUI.color ); } Rect trackLabelRect = trackHeaderRect; trackLabelRect.xMin += 10; GUI.Label(trackLabelRect, new GUIContent(_track.name), FGUI.GetTrackHeaderStyle()); rect.xMin = trackHeaderRect.xMax; FrameRange validKeyframeRange = new FrameRange(0, SequenceEditor.GetSequence().Length); for (int i = 0; i != _eventEditors.Count; ++i) { if (i == 0) { validKeyframeRange.Start = 0; } else { validKeyframeRange.Start = _eventEditors[i - 1]._evt.End; } if (i == _eventEditors.Count - 1) { validKeyframeRange.End = SequenceEditor.GetSequence().Length; } else { validKeyframeRange.End = _eventEditors[i + 1]._evt.Start; } _eventEditors[i].Render(rect, viewRange, pixelsPerFrame, validKeyframeRange); } switch (Event.current.type) { case EventType.ContextClick: if (trackHeaderRect.Contains(Event.current.mousePosition)) { GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent("Duplicate Track"), false, DuplicateTrack); menu.AddItem(new GUIContent("Delete Track"), false, DeleteTrack); menu.ShowAsContext(); Event.current.Use(); } break; case EventType.MouseDown: if (EditorGUIUtility.hotControl == 0 && trackHeaderRect.Contains(Event.current.mousePosition)) { if (Event.current.button == 0) // selecting { if (Event.current.control) { if (IsSelected()) { SequenceEditor.Deselect(this); } else { SequenceEditor.Select(this); } } else if (Event.current.shift) { SequenceEditor.Select(this); } else { SequenceEditor.SelectExclusive(this); _timelineEditor.StartTrackDrag(this); _offsetAnim.value = _offsetAnim.target = new Vector2(0, rect.yMin) - Event.current.mousePosition; EditorGUIUtility.hotControl = id; } Event.current.Use(); } } break; case EventType.MouseUp: if (EditorGUIUtility.hotControl == id) { EditorGUIUtility.hotControl = 0; _offsetAnim.value = _offsetAnim.target = Vector2.zero; _timelineEditor.StopTrackDrag(); SequenceEditor.Repaint(); Event.current.Use(); } break; case EventType.MouseDrag: if (EditorGUIUtility.hotControl == id) { SequenceEditor.Repaint(); Event.current.Use(); } break; } if (_track.CanTogglePreview()) { GUI.color = FGUI.GetTextColor(); if (!_track.IsPreviewing) { Color c = GUI.color; c.a = 0.3f; GUI.color = c; } GUI.DrawTexture(viewRect, _previewIcon); GUI.color = Color.white; } #if UNITY_4_5 if (_offsetAnim.isAnimating) { SequenceEditor.Repaint(); } #endif }