public void OnGUI() { FSequence sequence = _window.GetSequenceEditor().GetSequence(); FrameRange viewRange = _window.GetSequenceEditor().GetViewRange(); GUI.contentColor = FGUI.GetTextColor(); bool goToFirst = false; bool goToPrevious = false; bool goToNext = false; bool goToLast = false; if (Event.current.type == EventType.KeyDown) { if (Event.current.keyCode == KeyCode.Comma) { goToFirst = Event.current.shift; goToPrevious = !goToFirst; Event.current.Use(); _window.Repaint(); } if (Event.current.keyCode == KeyCode.Period) { goToLast = Event.current.shift; goToNext = !goToLast; Event.current.Use(); _window.Repaint(); } } if (GUI.Button(_firstFrameButtonRect, _firstFrame, EditorStyles.miniButtonLeft) || goToFirst) { GoToFrame(viewRange.Start); } if (GUI.Button(_previousFrameButtonRect, _previousFrame, EditorStyles.miniButtonMid) || goToPrevious) { GoToFrame(viewRange.Cull(sequence.GetCurrentFrame() - 1)); } GUIStyle numberFieldStyle = new GUIStyle(EditorStyles.numberField); numberFieldStyle.alignment = TextAnchor.MiddleCenter; // Debug.Log("hot control: " + EditorGUIUtility.hotControl + " keyboard control: " + EditorGUIUtility.keyboardControl ); if (sequence != null) { if (sequence.GetCurrentFrame() < 0) { EditorGUI.BeginChangeCheck(); string frameStr = EditorGUI.TextField(_currentFrameFieldRect, string.Empty, numberFieldStyle); if (EditorGUI.EndChangeCheck()) { int newCurrentFrame = 0; int.TryParse(frameStr, out newCurrentFrame); newCurrentFrame = Mathf.Clamp(newCurrentFrame, 0, sequence.Length); _window.GetSequenceEditor().SetCurrentFrame(newCurrentFrame); } } else { EditorGUI.BeginChangeCheck(); int newCurrentFrame = Mathf.Clamp(EditorGUI.IntField(_currentFrameFieldRect, sequence.GetCurrentFrame(), numberFieldStyle), 0, sequence.Length); if (EditorGUI.EndChangeCheck()) { _window.GetSequenceEditor().SetCurrentFrame(newCurrentFrame); } } } if (GUI.Button(_nextFrameButtonRect, _nextFrame, EditorStyles.miniButtonMid) || goToNext) { GoToFrame(viewRange.Cull(sequence.GetCurrentFrame() + 1)); } if (GUI.Button(_lastFrameButtonRect, _lastFrame, EditorStyles.miniButtonRight) || goToLast) { GoToFrame(viewRange.End); } // if( GUI.Button( _playBackwardButtonRect, _window.IsPlaying ? "[] Stop" : "< Play", EditorStyles.miniButtonLeft) ) // { // if( _window.IsPlaying ) // { // _window.Stop(); // } // else // { // _window.Play(); // } // } if (GUI.Button(_stopButtonRect, _stop, EditorStyles.miniButtonLeft)) { Stop(); } if (GUI.Button(_playForwardButtonRect, _window.IsPlaying ? _pause : _playForward, EditorStyles.miniButtonRight)) { if (_window.IsPlaying) { Pause(); } else { Play(); } } if (_showViewRange) { EditorGUI.PrefixLabel(_viewRangeLabelRect, _viewRangeLabel); EditorGUI.BeginChangeCheck(); viewRange.Start = EditorGUI.IntField(_viewRangeStartRect, viewRange.Start, numberFieldStyle); EditorGUI.PrefixLabel(_viewRangeDashRect, _viewRangeDash); viewRange.End = EditorGUI.IntField(_viewRangeEndRect, viewRange.End, numberFieldStyle); if (EditorGUI.EndChangeCheck()) { _window.GetSequenceEditor().SetViewRange(viewRange); } } }
public void OnGUI() { FSequence sequence = _sequenceWindow.GetSequenceEditor().GetSequence(); if (_selectedSequenceIndex < 0 && sequence != null) { for (int i = 0; i != _sequences.Length; ++i) { if (_sequences[i] == sequence) { _selectedSequenceIndex = i; break; } } } GUI.contentColor = FGUI.GetTextColor(); if (Event.current.type == EventType.MouseDown && Event.current.alt && _sequencePopupRect.Contains(Event.current.mousePosition)) { Selection.activeObject = sequence; Event.current.Use(); } EditorGUI.BeginChangeCheck(); EditorGUI.PrefixLabel(_sequenceLabelRect, _sequenceLabel); int newSequenceIndex = EditorGUI.Popup(_sequencePopupRect, _selectedSequenceIndex, _sequenceNames); if (EditorGUI.EndChangeCheck()) { _selectedSequenceIndex = newSequenceIndex; _sequenceWindow.GetSequenceEditor().OpenSequence(_sequences[_selectedSequenceIndex]); _sequenceWindow.RemoveNotification(); EditorGUIUtility.keyboardControl = 0; // deselect it EditorGUIUtility.ExitGUI(); } if (GUI.Button(_sequenceAddButtonRect, new GUIContent((Texture2D)AssetDatabase.LoadAssetAtPath(FUtility.GetFluxSkinPath() + "Plus.png", typeof(Texture2D)), "Create New Sequence.."), EditorStyles.label)) { FSequence newSequence = FSequenceEditorWindow.CreateSequence(); _sequenceWindow.GetSequenceEditor().OpenSequence(newSequence); EditorGUIUtility.ExitGUI(); } if (sequence == null) { return; } if (_sequenceSO == null || _sequenceSO.targetObject != sequence) { _sequenceSO = new SerializedObject(sequence); _sequenceUpdateMode = _sequenceSO.FindProperty("_updateMode"); _sequenceLength = _sequenceSO.FindProperty("_length"); } _sequenceSO.Update(); if (_showUpdadeMode) { EditorGUI.PrefixLabel(_updateModeLabelRect, _updateModeLabel); EditorGUI.PropertyField(_updateModeFieldRect, _sequenceUpdateMode, GUIContent.none); } if (_showFramerate) { EditorGUI.PrefixLabel(_framerateLabelRect, _framerateLabel); EditorGUI.BeginChangeCheck(); int newFrameRate = FGUI.FrameRatePopup(_framerateFieldRect, sequence.FrameRate); if (EditorGUI.EndChangeCheck()) { if (newFrameRate == -1) { FChangeFrameRateWindow.Show(new Vector2(_framerateLabelRect.xMin, _framerateLabelRect.yMax), sequence, FSequenceInspector.Rescale); } else { FSequenceInspector.Rescale(sequence, newFrameRate, true); } } } if (_showLength) { EditorGUI.PrefixLabel(_lengthLabelRect, _lengthLabel); _sequenceLength.intValue = EditorGUI.IntField(_lengthFieldRect, _sequenceLength.intValue, _numberFieldStyle); } _sequenceSO.ApplyModifiedProperties(); }