void OnGUI() { #if FLUX_PROFILE Profiler.BeginSample("Flux OnGUI"); #endif if (_sequenceEditor == null) { return; } Rect currentWindowRect = position; currentWindowRect.x = 0; currentWindowRect.y = 0; if (currentWindowRect != _windowRect) { RebuildLayout(); } if (!FUtility.RenderOnEditorPlay && EditorApplication.isPlaying && !EditorApplication.isPaused) { GUI.Label(_windowRect, "Draw in play mode is disabled. You can change it on Flux Preferences"); return; } FSequence sequence = _sequenceEditor.Sequence; if (sequence == null) { ShowNotification(new GUIContent("Select Or Create Sequence")); } else if (Event.current.isKey) { if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Return) { EditorGUIUtility.keyboardControl = 0; Event.current.Use(); Repaint(); } } // header _windowHeader.OnGUI(); if (sequence == null) { return; } // toolbar _toolbar.OnGUI(); switch (Event.current.type) { case EventType.KeyDown: if (Event.current.keyCode == KeyCode.Backspace || Event.current.keyCode == KeyCode.Delete) { _sequenceEditor.DestroyEvents(_sequenceEditor.EventSelection.Editors); Event.current.Use(); } break; case EventType.MouseDown: break; case EventType.MouseUp: break; } if (Event.current.type == EventType.ValidateCommand) { Repaint(); } _sequenceEditor.OnGUI(); // because of a bug with windows editor, we have to not catch right button // otherwise ContextClick doesn't get called if (Event.current.type == EventType.MouseUp && Event.current.button != 1) { Event.current.Use(); } if (Event.current.type == EventType.Ignore) { EditorGUIUtility.hotControl = 0; } if (Event.current.type == EventType.Repaint) { Handles.DrawLine(new Vector3(_windowHeaderRect.xMin, _windowHeaderRect.yMax, 0), new Vector3(_windowHeaderRect.xMax - FSequenceEditor.RIGHT_BORDER, _windowHeaderRect.yMax, 0)); } #if FLUX_PROFILE Profiler.EndSample(); #endif }
void OnGUI() { #if FLUX_PROFILE Profiler.BeginSample("Flux OnGUI"); #endif if (_sequenceEditor == null) { return; } Rect currentWindowRect = position; currentWindowRect.x = 0; currentWindowRect.y = 0; if (currentWindowRect != _windowRect) { RebuildLayout(); } if (!FUtility.RenderOnEditorPlay && EditorApplication.isPlaying && !EditorApplication.isPaused) { GUI.Label(_windowRect, "Draw in play mode is disabled. You can change it on Flux Preferences"); return; } FSequence sequence = _sequenceEditor.Sequence; if (sequence == null) { ShowNotification(new GUIContent("Select Or Create Sequence")); } else if (Event.current.isKey) { if (Event.current.keyCode == KeyCode.Space) { if (Event.current.type == EventType.KeyUp) { if (_sequenceEditor.IsPlaying) { if (Event.current.shift) { Stop(); } else { Pause(); } } else { Play(Event.current.shift); } Repaint(); } Event.current.Use(); } if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Return) { EditorGUIUtility.keyboardControl = 0; Event.current.Use(); Repaint(); } } // header _windowHeader.OnGUI(); if (sequence == null) { return; } // toolbar _toolbar.OnGUI(); switch (Event.current.type) { case EventType.KeyDown: if (Event.current.keyCode == KeyCode.Backspace || Event.current.keyCode == KeyCode.Delete) { _sequenceEditor.DestroyEvents(_sequenceEditor.EventSelection.Editors); Event.current.Use(); } else if (Event.current.keyCode == KeyCode.K && _sequenceEditor.Sequence.CurrentFrame >= 0) { _sequenceEditor.AddEvent(_sequenceEditor.Sequence.CurrentFrame); Event.current.Use(); } // else if( Event.current.keyCode == KeyCode.C && _sequenceEditor.GetSequence().GetCurrentFrame() >= 0 ) // { // _sequenceEditor.AddCommentEvent( _sequenceEditor.GetSequence().GetCurrentFrame() ); // Event.current.Use(); // } break; case EventType.MouseDown: break; case EventType.MouseUp: break; } if (Event.current.type == EventType.ValidateCommand) { Repaint(); } _sequenceEditor.OnGUI(); // because of a bug with windows editor, we have to not catch right button // otherwise ContextClick doesn't get called if (Event.current.type == EventType.MouseUp && Event.current.button != 1) { Event.current.Use(); } if (Event.current.type == EventType.Ignore) { EditorGUIUtility.hotControl = 0; } // // handle drag & drop // if( Event.current.type == EventType.DragUpdated ) // { // if( _windowRect.Contains( Event.current.mousePosition ) ) // { // DragAndDrop.visualMode = DragAndDropVisualMode.Link; // Event.current.Use(); // } // } // else if( Event.current.type == EventType.DragPerform ) // { // if( _windowRect.Contains( Event.current.mousePosition ) ) // { // foreach( UnityEngine.Object obj in DragAndDrop.objectReferences ) // { // if( !(obj is GameObject) ) // { // continue; // } // // PrefabType prefabType = PrefabUtility.GetPrefabType(obj); // if( prefabType == PrefabType.ModelPrefab || prefabType == PrefabType.Prefab ) // continue; // // Undo.IncrementCurrentGroup(); // UnityEngine.Object[] objsToSave = new UnityEngine.Object[]{ sequence, this }; // // Undo.RegisterCompleteObjectUndo( objsToSave, string.Empty ); // // GameObject timelineGO = new GameObject(obj.name); // // TODO //// FTimeline timeline = timelineGO.AddComponent<Flux.FTimeline>(); //// timeline.SetOwner( ((GameObject)obj).transform ); //// sequence.Add( timeline ); // //// Undo.RegisterCompleteObjectUndo( objsToSave, string.Empty ); //// Undo.RegisterCreatedObjectUndo( timeline.gameObject, "create Timeline" ); //// Undo.CollapseUndoOperations( Undo.GetCurrentGroup() ); // } // RemoveNotification(); // Event.current.Use(); // DragAndDrop.AcceptDrag(); // Refresh(); // EditorGUIUtility.ExitGUI(); // } // } if (Event.current.type == EventType.Repaint) { Handles.DrawLine(new Vector3(_windowHeaderRect.xMin, _windowHeaderRect.yMax, 0), new Vector3(_windowHeaderRect.xMax - FSequenceEditor.RIGHT_BORDER, _windowHeaderRect.yMax, 0)); } #if FLUX_PROFILE Profiler.EndSample(); #endif }