public void OnGUI() { FSequence sequence = _sequenceWindow.GetSequenceEditor().Sequence; if ((_selectedSequenceIndex < 0 && sequence != null) || (_selectedSequenceIndex >= 0 && _sequences[_selectedSequenceIndex] != sequence)) { for (int i = 0; i != _sequences.Length; ++i) { if (_sequences[i] == sequence) { _selectedSequenceIndex = i; break; } } } 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()) { if (newSequenceIndex == _sequenceNames.Length - 1) { FSequence newSequence = FSequenceEditorWindow.CreateSequence(); Selection.activeTransform = newSequence.transform; _sequenceWindow.GetSequenceEditor().OpenSequence(newSequence); } else { _selectedSequenceIndex = newSequenceIndex; _sequenceWindow.GetSequenceEditor().OpenSequence(_sequences[_selectedSequenceIndex]); _sequenceWindow.RemoveNotification(); } EditorGUIUtility.keyboardControl = 0; // deselect it EditorGUIUtility.ExitGUI(); } // if we're in play mode, can't change anything if (Application.isPlaying) { GUI.enabled = false; } if (sequence == null) { return; } if (_sequenceSO == null || _sequenceSO.targetObject != sequence) { _sequenceSO = new SerializedObject(sequence); _sequenceExecuteTime = _sequenceSO.FindProperty("_executeTime"); _sequenceUpdateMode = _sequenceSO.FindProperty("_updateMode"); _sequenceLength = _sequenceSO.FindProperty("_length"); } _sequenceSO.Update(); if (_showExecuteTime) { EditorGUI.PrefixLabel(_executeTimeLabelRect, _executeTimeLabel); //EditorGUI.PropertyField(_executeTimeFieldRect, _sequenceExecuteTime, _numberFieldStyle); _sequenceExecuteTime.intValue = EditorGUI.IntField(_executeTimeFieldRect, _sequenceExecuteTime.intValue, _numberFieldStyle); } 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 = Mathf.Clamp(EditorGUI.IntField(_lengthFieldRect, _sequenceLength.intValue, _numberFieldStyle), 1, int.MaxValue); } GUIStyle s = new GUIStyle(EditorStyles.miniButton); s.padding = new RectOffset(1, 1, 1, 1); if (_showAddContainer) { if (FGUI.Button(_addContainerRect, _addContainerLabel)) { AddContainer(); } } if (FGUI.Button(_openInspectorRect, _openInspectorLabel)) { FInspectorWindow.Open(); } _sequenceSO.ApplyModifiedProperties(); GUI.enabled = true; }
public override void Render(Rect rect, float headerWidth) { Rect = rect; HeaderWidth = headerWidth; Rect headerRect = rect; headerRect.width = headerWidth; Rect enableButtonRect = rect; enableButtonRect.xMax = rect.xMin + headerWidth; enableButtonRect.xMin = enableButtonRect.xMax - 16; enableButtonRect.height = 16; Rect trackHeaderRect = rect; trackHeaderRect.width = headerWidth; Color guiColor = GUI.color; bool selected = _isSelected; if (selected) { Color c = FGUI.GetSelectionColor(); c.a = GUI.color.a; GUI.color = c; GUI.DrawTexture(trackHeaderRect, EditorGUIUtility.whiteTexture); GUI.color = guiColor; } GUI.color = GetPreviewIconColor(); if (!Track.enabled) { Color c = guiColor; c.a = 0.5f; GUI.color = c; } if (FGUI.Button(enableButtonRect, _enableContent)) { if (Event.current.shift) // turn all? { SequenceEditor.EnableAllTracks(!Track.enabled); } else { OnToggle(!Track.enabled); } FUtility.RepaintGameView(); Event.current.Use(); } Rect trackLabelRect = trackHeaderRect; trackLabelRect.xMin += 8; RenderHeader(trackLabelRect, new GUIContent(Track.name)); rect.xMin = trackHeaderRect.xMax; if (rect.Contains(Event.current.mousePosition)) { SequenceEditor.SetMouseHover(Event.current.mousePosition.x - rect.xMin, this); } FrameRange validKeyframeRange = new FrameRange(0, SequenceEditor.Sequence.Length); _contentOffset = rect.min; GUI.BeginGroup(rect); rect.x = 0; rect.y = 0; 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.Sequence.Length; } else { validKeyframeRange.End = _eventEditors[i + 1].Evt.Start; } rect.xMin = SequenceEditor.GetXForFrame(_eventEditors[i].Evt.Start); rect.xMax = SequenceEditor.GetXForFrame(_eventEditors[i].Evt.End); _eventEditors[i].Render(rect, SequenceEditor.ViewRange, SequenceEditor.PixelsPerFrame, validKeyframeRange); } GUI.EndGroup(); switch (Event.current.type) { case EventType.ContextClick: if (trackHeaderRect.Contains(Event.current.mousePosition)) { OnHeaderContextClick(); } else if (Rect.Contains(Event.current.mousePosition)) { OnBodyContextClick(); } 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); } Event.current.Use(); } } break; case EventType.MouseUp: break; case EventType.MouseDrag: break; } Handles.color = FGUI.GetLineColor(); Handles.DrawLine(Rect.min, Rect.min + new Vector2(Rect.width, 0)); Handles.DrawLine(Rect.max, Rect.max - new Vector2(Rect.width, 0)); GUI.color = guiColor; }
public void OnGUI() { FSequence sequence = _sequenceWindow.GetSequenceEditor().Sequence; if ((_selectedSequenceIndex < 0 && sequence != null) || (_selectedSequenceIndex >= 0 && _sequences[_selectedSequenceIndex] != sequence)) { for (int i = 0; i != _sequences.Length; ++i) { if (_sequences[i] == sequence) { _selectedSequenceIndex = i; break; } } } if (FGUI.Button(_loadRect, _loadLabel)) { LoadSequence(); } EditorGUI.BeginChangeCheck(); EditorGUI.PrefixLabel(_sequenceLabelRect, _sequenceLabel); int newSequenceIndex = EditorGUI.Popup(_sequencePopupRect, _selectedSequenceIndex, _sequenceNames); if (EditorGUI.EndChangeCheck()) { if (newSequenceIndex == _sequenceNames.Length - 1) { FSequence newSequence = FSequenceEditorWindow.CreateSequence(); Selection.activeTransform = newSequence.transform; _sequenceWindow.GetSequenceEditor().OpenSequence(newSequence); } else { _selectedSequenceIndex = newSequenceIndex; _sequenceWindow.GetSequenceEditor().OpenSequence(_sequences[_selectedSequenceIndex]); _sequenceWindow.RemoveNotification(); } EditorGUIUtility.keyboardControl = 0; // deselect it EditorGUIUtility.ExitGUI(); } if (sequence == null) { return; } if (_sequenceSO == null || _sequenceSO.targetObject != sequence) { _sequenceSO = new SerializedObject(sequence); _sequenceLength = _sequenceSO.FindProperty("_length"); } _sequenceSO.Update(); EditorGUI.PrefixLabel(_lengthLabelRect, _lengthLabel); _sequenceLength.intValue = Mathf.Clamp(EditorGUI.IntField(_lengthFieldRect, _sequenceLength.intValue, _numberFieldStyle), 1, int.MaxValue); GUIStyle s = new GUIStyle(EditorStyles.miniButton); s.padding = new RectOffset(1, 1, 1, 1); if (FGUI.Button(_addContainerRect, _addContainerLabel)) { AddContainer(); } if (FGUI.Button(_openInspectorRect, _openInspectorLabel)) { FInspectorWindow.Open(); } if (FGUI.Button(_saveRect, _saveLabel)) { Save(sequence); } if (FGUI.Button(_saveAllRect, _saveAllLabel)) { SaveAll(); } _sequenceSO.ApplyModifiedProperties(); GUI.enabled = true; }