Exemple #1
0
        private void OnDragSelecting(Vector2 mousePos)
        {
            if (!_isDragSelecting)
            {
                return;
            }

            if (Event.current.shift)
            {
                EditorGUIUtility.AddCursorRect(_rect, MouseCursor.ArrowPlus);
            }
            else if (Event.current.control)
            {
                EditorGUIUtility.AddCursorRect(_rect, MouseCursor.ArrowMinus);
            }

            FrameRange selectedRange = new FrameRange();
            bool       isSelectingTimelines;

            Rect selectionRect = GetDragSelectionRect(_dragSelectingStartPos, mousePos, out selectedRange, out isSelectingTimelines);

            if (selectionRect.width == 0)
            {
                selectionRect.width = 1;
            }
            GUI.color = FGUI.GetSelectionColor();
            GUI.DrawTexture(selectionRect, EditorGUIUtility.whiteTexture);
        }
Exemple #2
0
        public override void Render(Rect rect, float headerWidth)
        {
            Rect = rect;

            Rect headerRect = rect;

            headerRect.height = HeaderHeight;
            RenderHeader(headerRect, headerWidth);

            Rect headerTimelineRect = rect;

            headerTimelineRect.xMin += headerWidth;
            if (headerTimelineRect.Contains(Event.current.mousePosition))
            {
                SequenceEditor.SetMouseHover(Event.current.mousePosition.x - headerWidth, this);
            }

            headerRect.width = headerWidth;
            HeaderRect       = headerRect;

            Rect listRect = rect;

            listRect.yMin += HeaderHeight;

            _contentOffset.y = listRect.y;

            if (_showPercentage.value > 0)
            {
                listRect.height *= _showPercentage.value;
                RenderList(listRect, headerWidth);
            }

            if (IsSelected && Event.current.type == EventType.Repaint)
            {
                float lineWidth     = 3;
                float halfLineWidth = lineWidth * 0.33f;
                Color c             = Handles.selectedColor;    //FGUI.GetTextColor();//Color.white;//new Color(0.5f, 0.7f, 0.1f, 1f);//FGUI.GetSelectionColor();
                c.a           = 1f;
                Handles.color = c;
                Vector3 pt0 = new Vector3(rect.xMin + halfLineWidth, rect.yMin + halfLineWidth);
                Vector3 pt1 = new Vector3(rect.xMin + halfLineWidth, rect.yMax - halfLineWidth);
                Vector3 pt2 = new Vector3(rect.xMax - halfLineWidth, rect.yMax - halfLineWidth);
                Vector3 pt3 = new Vector3(rect.xMax - halfLineWidth, rect.yMin + halfLineWidth);
//				Handles.DrawAAPolyLine( lineWidth, pt0, pt1, pt2, pt3, pt0 );
                Handles.DrawSolidRectangleWithOutline(new Vector3[] { pt0, pt1, pt2, pt3 }, new Color(0, 0, 0, 0), c);
                //				Handles.DrawPolyLine( pt0, pt1, pt2, pt3, pt0 );
            }

            Handles.color = FGUI.GetLineColor();
            Handles.DrawLine(Rect.min, Rect.min + new Vector2(Rect.width, 0));
            Handles.DrawLine(Rect.max - new Vector2(Rect.width, 0), Rect.max);
        }
Exemple #3
0
        public Color GetEventColor(string str)
        {
            if (_eventColorsHash == null)
            {
                Init();
            }
            //			Debug.Log ( eventTypeStr );
            FColorSetting c;

            if (!_eventColorsHash.TryGetValue(str, out c))
            {
                return(FGUI.GetEventColor());
            }
            return(c._color);
        }
Exemple #4
0
        public void OnGUI()
        {
            FrameRange viewRange = _window.GetSequenceEditor().ViewRange;

            GUI.backgroundColor = Color.white;
            GUI.contentColor    = FGUI.GetTextColor();
            GUIStyle numberFieldStyle = new GUIStyle(EditorStyles.numberField);

            numberFieldStyle.alignment = TextAnchor.MiddleCenter;

            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);
                }
            }
        }
Exemple #5
0
        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;
        }
Exemple #6
0
        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;
        }
Exemple #7
0
 protected virtual void RenderHeader(Rect labelRect, GUIContent label)
 {
     GUI.Label(labelRect, label, FGUI.GetTrackHeaderStyle());
 }
Exemple #8
0
        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
        }
Exemple #9
0
        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;
                    }
                }
            }


//			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())
            {
                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);
                _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);
                    }
                }
            }

//			FSequenceEditor sequenceEditor = _sequenceWindow.GetSequenceEditor();

            // if it gets resized, we need to set the view range a
//			bool setViewRange = false;

//			FrameRange viewRange = sequenceEditor.GetViewRange();

            if (_showLength)
            {
                EditorGUI.PrefixLabel(_lengthLabelRect, _lengthLabel);
//				EditorGUI.BeginChangeCheck();
                _sequenceLength.intValue = Mathf.Clamp(EditorGUI.IntField(_lengthFieldRect, _sequenceLength.intValue, _numberFieldStyle), 1, int.MaxValue);

//				if( EditorGUI.EndChangeCheck() )
//				{
//					float viewRangePercentage = (float)viewRange.Length / sequenceEditor.GetSequence().Length;
//
//					if( viewRange.End > _sequenceLength.intValue )
//					{
//						viewRange.End = _sequenceLength.intValue;
//						if( viewRange.Start > viewRange.End )
//						{
//							viewRange.Start = viewRange.End;
//						}
//					}
//					else
//					{
//						viewRange.End = Mathf.Clamp( viewRange.Start + Mathf.RoundToInt(_sequenceLength.intValue * viewRangePercentage), viewRange.Start, _sequenceLength.intValue );
//					}
//
//					setViewRange = true;
//				}
            }

            if (_showAddContainer)
            {
                if (GUI.Button(_addContainerRect, _addContainerLabel, EditorStyles.label))
                {
                    AddContainer();
                }
            }

            _sequenceSO.ApplyModifiedProperties();

//			if( setViewRange )
//			{
//				sequenceEditor.SetViewRange( viewRange );
//			}

            GUI.enabled = true;
        }
Exemple #10
0
        public void OnGUI()
        {
            if (_timelineEditors == null)
            {
                return;
            }

            if (_timelineEditors.Count == 0)
            {
                if (_renderingOnEditorWindow)
                {
                    _renderingOnEditorWindow.ShowNotification(new GUIContent("Drag GameObjects Here"));
                }
            }

            _pixelsPerFrame = (_sequenceRect.width - _timelineHeaderWidth) / _viewRange.Length;

            if (_timelineEditorIds.Length != _timelineEditors.Count)
            {
                _timelineEditorIds     = new int[_timelineEditors.Count];
                _timelineEditorHeights = new float[_timelineEditors.Count];
            }

            int timelineHeaderResizerId = EditorGUIUtility.GetControlID(FocusType.Passive);

            float sequenceViewHeight = 0;

            for (int i = 0; i != _timelineEditors.Count; ++i)
            {
                _timelineEditorIds[i]     = EditorGUIUtility.GetControlID(FocusType.Passive);
                _timelineEditorHeights[i] = _timelineEditors[i].GetHeight();
                sequenceViewHeight       += _timelineEditorHeights[i];

                _timelineEditors[i].ReserveTrackGuiIds();
            }

            _scrollPos.y = GUI.VerticalScrollbar(_verticalScrollerRect, _scrollPos.y, Mathf.Min(_sequenceRect.height, sequenceViewHeight), 0, sequenceViewHeight);

            Rect scrolledViewRect = _viewRect;

//			scrolledViewRect.yMin -= _scrollPos.y;

            GUI.BeginGroup(scrolledViewRect);

            Rect timelineRect = _sequenceRect;

            timelineRect.y      = -_scrollPos.y;
            timelineRect.height = 0;

            Rect timelineDraggedRect = new Rect();

//			Debug.Log( "sequence: " + _sequenceRect + " scrubber: " + _timeScrubberRect + " width: " + _timelineHeaderWidth );

            Handles.color = FGUI.GetLineColor();

            for (int i = 0; i != _timelineEditors.Count; ++i)
            {
                timelineRect.yMin   = timelineRect.yMax;
                timelineRect.height = _timelineEditors[i].GetHeight();

                if (_timelineDragged != null)
                {
                    if (_timelineDragged == _timelineEditors[i])
                    {
                        timelineDraggedRect = timelineRect;
                        continue;
                    }
                    else if (EditorGUIUtility.hotControl == _timelineEditorIds[_timelineDragged.GetRuntimeObject().GetId()])
                    {
                        if (i < _timelineDragged.GetRuntimeObject().GetId() && Event.current.mousePosition.y < timelineRect.yMax)
                        {
                            _timelineEditors[i].SetOffset(new Vector2(0, _timelineDragged.GetHeight()));
                        }
                        else if (i > _timelineDragged.GetRuntimeObject().GetId() && Event.current.mousePosition.y > timelineRect.yMin)
                        {
                            _timelineEditors[i].SetOffset(new Vector2(0, -_timelineDragged.GetHeight()));
                        }
                        else
                        {
                            _timelineEditors[i].SetOffset(Vector2.zero);
                        }
                    }
                }

                _timelineEditors[i].Render(_timelineEditorIds[i], timelineRect, _timelineHeaderWidth, _viewRange, _pixelsPerFrame);
            }

            if (_timelineDragged != null)
            {
                if (EditorGUIUtility.hotControl == _timelineEditorIds[_timelineDragged.GetRuntimeObject().GetId()])
                {
                    timelineDraggedRect.y = Event.current.mousePosition.y;
                }
//				timelineRect.yMin = Event.current.mousePosition.y;
//				timelineRect.height = _timelineDragged.GetHeight();
                _timelineDragged.Render(_timelineEditorIds[_timelineDragged.GetRuntimeObject().GetId()], timelineDraggedRect, _timelineHeaderWidth, _viewRange, _pixelsPerFrame);
            }

            switch (Event.current.type)
            {
            case EventType.MouseDown:

//				bool middleClick = Event.current.button == 2 || (Event.current.button == 0 && Event.current.alt);
//
//				if( middleClick ) // middle button
                if (Event.current.button == 0)
                {
                    StartDragSelecting(Event.current.mousePosition);
                    Event.current.Use();
                }
                break;

            case EventType.MouseUp:
                if (_isDragSelecting)
                {
                    StopDragSelecting(Event.current.mousePosition);
                    Event.current.Use();
                }
                break;

            case EventType.Ignore:
                if (_isDragSelecting)
                {
                    StopDragSelecting(Event.current.mousePosition);
                }
                break;

            case EventType.Repaint:
                if (_isDragSelecting)
                {
                    OnDragSelecting(Event.current.mousePosition);
                }

                break;
            }

            GUI.EndGroup();

            if (_viewRange.End > _sequence.Length)
            {
                _viewRange.Start = 0;
                _viewRange.End   = _sequence.Length;
            }

            int newT = FGUI.TimeScrubber(_timeScrubberRect, _sequence.GetCurrentFrame(), _sequence.FrameRate, _viewRange);

            if (newT != _sequence.GetCurrentFrame())
            {
//				_sequence.SetCurrentFrameEditor( newT );
                SetCurrentFrame(newT);

                if (Application.isPlaying)
                {
                    Play(false);
                    Pause();
                }
//				Repaint();
//				SceneView.RepaintAll();
//				UnityEditorInternal.InternalEditorUtility.RepaintAllViews();
//				FUtility.RepaintGameView();
            }

            _viewRange = FGUI.ViewRangeBar(_viewRangeRect, _viewRange, _sequence.Length);

            if (_timelineHeaderResizerRect.Contains(Event.current.mousePosition))
            {
                EditorGUIUtility.AddCursorRect(_timelineHeaderResizerRect, MouseCursor.ResizeHorizontal);
            }

            switch (Event.current.type)
            {
            case EventType.MouseDown:

                bool leftClick = Event.current.button == 0 && !Event.current.alt;
//				bool middleClick = Event.current.button == 2 || (Event.current.button == 0 && Event.current.alt);

                if (leftClick)                  // left button
                {
                    if (EditorGUIUtility.hotControl == 0 && _timelineHeaderResizerRect.Contains(Event.current.mousePosition))
                    {
                        EditorGUIUtility.hotControl = timelineHeaderResizerId;
                        Event.current.Use();
                    }
                    else if (_rect.Contains(Event.current.mousePosition))
                    {
                        DeselectAll();
                        Event.current.Use();
                    }
                }
//				else if( middleClick ) // middle button
//				{
//					StartDragSelecting( Event.current.mousePosition );
//					Event.current.Use();
//				}
                break;

            case EventType.MouseDrag:
                if (EditorGUIUtility.hotControl == timelineHeaderResizerId)
                {
                    _timelineHeaderWidth = (int)Mathf.Max(MINIMUM_HEADER_WIDTH, _timelineHeaderWidth + Event.current.delta.x);

                    RebuildLayout(_rect);
                    EditorWindow.GetWindow <FSequenceEditorWindow>().Repaint();
                    Event.current.Use();
                }

                if (_isDragSelecting)
                {
                    Repaint();
                }

                break;

            case EventType.MouseUp:
                if (EditorGUIUtility.hotControl == timelineHeaderResizerId)
                {
                    EditorGUIUtility.hotControl = 0;
                    Event.current.Use();
                }
//				if( _isDragSelecting )
//				{
//					StopDragSelecting( Event.current.mousePosition );
//					Event.current.Use();
//				}
                break;

            case EventType.Repaint:
                Rect dragArea = _timelineHeaderResizerRect;
                dragArea.xMax -= 10;
                dragArea.xMin  = dragArea.xMax - 16;
                GUIStyle dragStyle = FUtility.GetFluxSkin().GetStyle("HorizontalPanelSeparatorHandle");
                dragStyle.Draw(dragArea, GUIContent.none, 0);
//				GUI.DrawTexture( dragArea, EditorGUIUtility.whiteTexture );
                Handles.color = FGUI.GetLineColor();                // new Color(0.8f, 0.8f, 0.8f, 0.2f);
                Handles.DrawLine(new Vector3(_viewRect.xMin - 16, _sequenceRect.yMax, 0), new Vector3(_viewRect.xMax - RIGHT_BORDER, _sequenceRect.yMax, 0));
//				Handles.color = Color.black;
                break;

            case EventType.ScrollWheel:
                if (_viewRect.Contains(Event.current.mousePosition))
                {
                    _scrollPos.y += Event.current.delta.y * SCROLL_WHEEL_SPEED;
                    Event.current.Use();
                }
                break;
            }

#if FLUX_TRIAL
            GUIStyle watermarkLabel = new GUIStyle(GUI.skin.label);
            watermarkLabel.fontSize = 24;
            GUIContent watermark     = new GUIContent("..::FLUX TRIAL::..");
            Vector2    watermarkSize = watermarkLabel.CalcSize(watermark);
            Rect       watermarkRect = new Rect(_rect.width * 0.5f - watermarkSize.x * 0.5f, _rect.height * 0.5f - watermarkSize.y * 0.5f, watermarkSize.x, watermarkSize.y);

            GUI.color = new Color(1f, 1f, 1f, 0.4f);
            GUI.Label(watermarkRect, watermark, watermarkLabel);
#endif
        }
Exemple #11
0
        public override void Render(Rect rect, float headerWidth)
        {
            Rect = rect;

            _headerWidth = headerWidth;

            Rect headerRect = rect;

            headerRect.width = headerWidth;

            Rect viewRect = rect;

            viewRect.xMax   = rect.xMin + 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?
                        {
                            if (Event.current.shift)                            // turn all?
                            {
                                SequenceEditor.TurnOnAllPreviews(!Track.CanPreview);
                            }
                            else
                            {
                                OnTogglePreview(!Track.CanPreview);
                            }
                            FUtility.RepaintGameView();
                            Event.current.Use();
                        }
                    }
                }
            }

            Rect trackHeaderRect = rect;

            trackHeaderRect.xMax = viewRect.xMax;            //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;
            }

            if (!Track.enabled)
            {
                Color c = guiColor;
                c.a       = 0.5f;
                GUI.color = c;
            }

            Rect trackLabelRect = trackHeaderRect;

            trackLabelRect.xMin += 8;

            GUI.Label(trackLabelRect, new GUIContent(Track.name), FGUI.GetTrackHeaderStyle());

            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);

            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;
                }
                _eventEditors[i].Render(rect, SequenceEditor.ViewRange, SequenceEditor.PixelsPerFrame, validKeyframeRange);
            }

            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:
//				if( EditorGUIUtility.hotControl == GuiId )
//				{
//					EditorGUIUtility.hotControl = 0;
//					_offsetAnim.value = _offsetAnim.target = Vector2.zero;
//
////					if( TimelineEditor ) TimelineEditor.StopTrackDrag();
//
//					SequenceEditor.Repaint();
//					Event.current.Use();
//				}
                break;

            case EventType.MouseDrag:
//				if( EditorGUIUtility.hotControl == GuiId )
//				{
//					SequenceEditor.Repaint();
//					Event.current.Use();
//				}
                break;
            }

            if (Track.CanTogglePreview)
            {
                GUI.color = GetPreviewIconColor();                //FGUI.GetTextColor();

                if (!Track.CanPreview)
                {
                    Color c = GUI.color;
                    c.a       = 0.3f;
                    GUI.color = c;
                }

                GUI.DrawTexture(viewRect, _previewIcon);

                GUI.color = Color.white;
            }

            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().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();
        }
        public void Render(int id, Rect rect, int hierarchyWidth, FrameRange viewRange, float pixelsPerFrame)
        {
            if (_timeline == null)
            {
                return;
            }

            rect.y += _offsetAnim.value.y;

            _rect = rect;

            float alpha = 1;

            if (EditorGUIUtility.hotControl == id)
            {
                rect.xMin += 5;
                rect.xMax -= 5;
                alpha      = 0.7f;
                Color c = GUI.color; c.a = alpha;
                GUI.color = c;
            }

            Rect hierarchyHeaderRect = rect; hierarchyHeaderRect.width = hierarchyWidth; hierarchyHeaderRect.height = HEADER_HEIGHT;

            Rect timelineHeaderRect = rect; timelineHeaderRect.height = HEADER_HEIGHT;

            Rect trackRect = timelineHeaderRect;

            trackRect.yMin   = timelineHeaderRect.yMax;
            trackRect.height = TRACK_HEIGHT;

            if (Event.current.type == EventType.Repaint)
            {
                GUI.color = FGUI.GetTimelineColor();
                GUI.DrawTexture(timelineHeaderRect, EditorGUIUtility.whiteTexture);
                GUI.color = new Color(1f, 1f, 1f, alpha);
            }

            if (_showTracks)
            {
                for (int i = 0; i != _trackEditors.Count; ++i)
                {
                    Vector3 upperLeft = trackRect.min;
                    Handles.color = FGUI.GetLineColor();

                    if (_trackDragged != null)
                    {
                        if (_trackDragged == _trackEditors[i])
                        {
                            Handles.DrawLine(upperLeft, upperLeft + new Vector3(trackRect.width, 0, 0));
                            trackRect.y += TRACK_HEIGHT;
                            continue;
                        }

                        if (i < _trackDragged.GetRuntimeObject().GetId() && Event.current.mousePosition.y < trackRect.yMax)
                        {
                            _trackEditors[i].SetOffset(new Vector2(0, TRACK_HEIGHT));
                        }
                        else if (i > _trackDragged.GetRuntimeObject().GetId() && Event.current.mousePosition.y > trackRect.yMin)
                        {
                            _trackEditors[i].SetOffset(new Vector2(0, -TRACK_HEIGHT));
                        }
                        else
                        {
                            _trackEditors[i].SetOffset(Vector2.zero);
                        }
                    }

                    GUI.color = new Color(0.3f, 0.3f, 0.3f, alpha);

                    GUI.color = new Color(1f, 1f, 1f, alpha);
                    _trackEditors[i].Render(_trackEditorIds[i], trackRect, hierarchyWidth, viewRange, pixelsPerFrame);

                    Handles.DrawLine(upperLeft, upperLeft + new Vector3(trackRect.width, 0, 0));

                    trackRect.y += TRACK_HEIGHT;
                }

                if (_trackDragged != null)
                {
                    Rect r = trackRect;
                    r.y = Event.current.mousePosition.y;
                    _trackDragged.Render(_trackEditorIds[_trackDragged.GetRuntimeObject().GetId()], r, hierarchyWidth, viewRange, pixelsPerFrame);
                }
            }

            Rect hierarchyLabelRect = hierarchyHeaderRect;

            hierarchyLabelRect.height = 20;
            hierarchyLabelRect.xMax   = hierarchyLabelRect.xMax - 23;

            Rect foldoutRect = hierarchyLabelRect;

            foldoutRect.width        = 16;
            hierarchyLabelRect.xMin += 16;

            string timelineHeaderName = _timeline.Owner != null ? _timeline.Owner.name : _timeline.name + " (Missing)";

            GUI.Label(hierarchyLabelRect, new GUIContent(timelineHeaderName), FGUI.GetTimelineHeaderStyle());

            _showTracks = EditorGUI.Foldout(foldoutRect, _showTracks, GUIContent.none);

            switch (Event.current.type)
            {
            case EventType.ContextClick:
                if (hierarchyHeaderRect.Contains(Event.current.mousePosition))
                {
                    GenericMenu menu = new GenericMenu();

                    if (Selection.activeGameObject == null || PrefabUtility.GetPrefabType(Selection.activeGameObject) == PrefabType.Prefab || PrefabUtility.GetPrefabType(Selection.activeGameObject) == PrefabType.ModelPrefab)
                    {
                        menu.AddDisabledItem(new GUIContent("Change Owner"));
                    }
                    else
                    {
                        menu.AddItem(new GUIContent("Change Owner to " + Selection.activeGameObject.name), false, ChangeOwner);
                    }

                    menu.AddItem(new GUIContent("Duplicate Timeline"), false, DuplicateTimeline);
                    menu.AddItem(new GUIContent("Delete Timeline"), false, DeleteTimeline);
                    menu.AddItem(new GUIContent("Add Timeline"), false, AddTimeline);

                    menu.ShowAsContext();
                    Event.current.Use();
                }
                break;

            case EventType.MouseDrag:
                if (EditorGUIUtility.hotControl == id)
                {
                    SequenceEditor.Repaint();
                    Event.current.Use();
                }
                break;

            case EventType.MouseUp:
                if (EditorGUIUtility.hotControl == id)
                {
                    EditorGUIUtility.hotControl = 0;
                    _offsetAnim.value           = _offsetAnim.target = Vector2.zero;
                    SequenceEditor.Repaint();

                    SequenceEditor.StopTimelineDrag();
                    Event.current.Use();
                }
                break;

            case EventType.Repaint:
                Handles.color = FGUI.GetLineColor();
                Handles.DrawLine(new Vector3(rect.xMin, rect.yMax, 0), new Vector3(rect.xMax, rect.yMax, 0));
                break;

            case EventType.KeyDown:
                if (EditorGUIUtility.hotControl == id && Event.current.keyCode == KeyCode.Escape)
                {
                    EditorGUIUtility.hotControl = 0;
                    Event.current.Use();
                }
                break;
            }

            Rect timelineOptionsRect = hierarchyHeaderRect;

            timelineOptionsRect.xMin   = hierarchyHeaderRect.xMax - 20;
            timelineOptionsRect.yMin   = hierarchyHeaderRect.yMin;
            timelineOptionsRect.width  = 14;
            timelineOptionsRect.height = 14;

            if (Event.current.type == EventType.MouseDown && timelineOptionsRect.Contains(Event.current.mousePosition))
            {
                Event.current.Use();

                GenericMenu menu  = new GenericMenu();
                Type[]      types = typeof(FEvent).Assembly.GetTypes();
                List <KeyValuePair <Type, FEventAttribute> > validTypeList = new List <KeyValuePair <Type, FEventAttribute> >();

                foreach (Type t in types)
                {
                    if (!typeof(FEvent).IsAssignableFrom(t))
                    {
                        continue;
                    }

                    object[] attributes = t.GetCustomAttributes(typeof(FEventAttribute), false);
                    if (attributes.Length == 0)
                    {
                        continue;
                    }

                    validTypeList.Add(new KeyValuePair <Type, FEventAttribute>(t, (FEventAttribute)attributes[0]));
                }

                validTypeList.Sort(delegate(KeyValuePair <Type, FEventAttribute> x, KeyValuePair <Type, FEventAttribute> y)
                {
                    return(x.Value.menu.CompareTo(y.Value.menu));
                });

                foreach (KeyValuePair <Type, FEventAttribute> kvp in validTypeList)
                {
                    menu.AddItem(new GUIContent(kvp.Value.menu), false, AddTrackMenu, kvp);
                }

                menu.ShowAsContext();
            }

            GUI.color = FGUI.GetTextColor();

            GUI.DrawTexture(timelineOptionsRect, (Texture2D)AssetDatabase.LoadAssetAtPath(FUtility.GetFluxSkinPath() + "Plus.png", typeof(Texture2D)));

            if (Event.current.type == EventType.MouseDown && hierarchyHeaderRect.Contains(Event.current.mousePosition))
            {
                if (Event.current.button == 0)                  // dragging
                {
                    EditorGUIUtility.hotControl = id;

                    _offsetAnim.value = _offsetAnim.target = new Vector2(0, hierarchyHeaderRect.yMin) - Event.current.mousePosition;

                    SequenceEditor.StartTimelineDrag(this);

                    Event.current.Use();
                }
            }

#if UNITY_4_5
            if (_offsetAnim.isAnimating)
            {
                _sequenceEditor.Repaint();
            }
#endif
        }
Exemple #14
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            Rect r = GUILayoutUtility.GetRect(EditorGUIUtility.currentViewWidth, EditorGUIUtility.singleLineHeight);

            r.width -= EditorGUIUtility.labelWidth;

            EditorGUI.PrefixLabel(r, new GUIContent("Frame Rate"));

            r.width += EditorGUIUtility.labelWidth;

            EditorGUI.BeginChangeCheck();
            r.xMin += EditorGUIUtility.labelWidth;

            int frameRate = FGUI.FrameRatePopup(r, _sequence.FrameRate);

            if (EditorGUI.EndChangeCheck())
            {
                if (frameRate == -1)
                {
                    FChangeFrameRateWindow.Show(new Vector2(r.xMin - EditorGUIUtility.labelWidth, r.yMax), _sequence, FSequenceInspector.Rescale);
                    EditorGUIUtility.ExitGUI();
                }
                else
                {
                    Rescale(_sequence, frameRate, true);
                }
            }

            serializedObject.Update();

            EditorGUILayout.PropertyField(_onFinishedCallback);

            EditorGUILayout.Space();

            if (GUILayout.Button("Open In Flux Editor"))
            {
                FSequenceEditorWindow.Open(_sequence);
            }

            EditorGUILayout.Space();

            if (GUILayout.Button(_advancedInspector ? "Normal Inspector" : "Advanced Inspector"))
            {
                _advancedInspector = !_advancedInspector;
            }

            if (_advancedInspector)
            {
//				serializedObject.Update();
                EditorGUILayout.PropertyField(_content);
//				serializedObject.ApplyModifiedProperties();

                bool showContent = (_sequence.Content.hideFlags & HideFlags.HideInHierarchy) == 0;

                EditorGUI.BeginChangeCheck();
                showContent = EditorGUILayout.Toggle("Show Content", showContent);
//				bool showTimelines = EditorGUILayout.Toggle( "Show Timelines", (_timelineContainer.objectReferenceValue.hideFlags & HideFlags.HideInHierarchy) == 0 );
                if (EditorGUI.EndChangeCheck())
                {
                    if (showContent)
                    {
//						_timelineContainer.objectReferenceValue.hideFlags &= ~HideFlags.HideInHierarchy;
                        _sequence.Content.transform.hideFlags &= ~HideFlags.HideInHierarchy;
//						for( int i = 0; i != _sequence.Containers.Count; ++i )
//							_sequence.Containers[i].transform.hideFlags &= ~HideFlags.HideInHierarchy;
                    }
                    else
                    {
                        _sequence.Content.transform.hideFlags |= HideFlags.HideInHierarchy;
//						_timelineContainer.objectReferenceValue.hideFlags |= HideFlags.HideInHierarchy;
//						for( int i = 0; i != _sequence.Containers.Count; ++i )
//							_sequence.Containers[i].transform.hideFlags |= HideFlags.HideInHierarchy;
                    }
                }
            }
            serializedObject.ApplyModifiedProperties();
//			serializedObject.ApplyModifiedProperties();
//			if( GUILayout.Button("Play") )
//				_sequence.Play();
        }
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            Rect r = GUILayoutUtility.GetRect(EditorGUIUtility.currentViewWidth, EditorGUIUtility.singleLineHeight);

            r.width -= EditorGUIUtility.labelWidth;

            EditorGUI.PrefixLabel(r, new GUIContent("Frame Rate"));

            r.width += EditorGUIUtility.labelWidth;

            EditorGUI.BeginChangeCheck();
            r.xMin += EditorGUIUtility.labelWidth;

            int frameRate = FGUI.FrameRatePopup(r, _sequence.FrameRate);

            if (EditorGUI.EndChangeCheck())
            {
                if (frameRate == -1)
                {
                    FChangeFrameRateWindow.Show(new Vector2(r.xMin - EditorGUIUtility.labelWidth, r.yMax), _sequence, FSequenceInspector.Rescale);
                    EditorGUIUtility.ExitGUI();
                }
                else
                {
                    Rescale(_sequence, frameRate, true);
                }
            }

            EditorGUILayout.Space();

            if (GUILayout.Button("Open In Flux Editor"))
            {
                FSequenceEditorWindow.Open(_sequence);
            }

            EditorGUILayout.Space();

            if (GUILayout.Button(_advancedInspector ? "Normal Inspector" : "Advanced Inspector"))
            {
                _advancedInspector = !_advancedInspector;
            }

            if (_advancedInspector)
            {
                EditorGUILayout.PropertyField(_timelineContainer);

                EditorGUI.BeginChangeCheck();
                bool showTimelines = EditorGUILayout.Toggle("Show Timelines", (_timelineContainer.objectReferenceValue.hideFlags & HideFlags.HideInHierarchy) == 0);
                if (EditorGUI.EndChangeCheck())
                {
                    if (showTimelines)
                    {
                        _timelineContainer.objectReferenceValue.hideFlags &= ~HideFlags.HideInHierarchy;
                    }
                    else
                    {
                        _timelineContainer.objectReferenceValue.hideFlags |= HideFlags.HideInHierarchy;
                    }
                }
            }

//			if( GUILayout.Button("Play") )
//				_sequence.Play();
        }
Exemple #16
0
 public virtual Color GetColor()
 {
     return(FGUI.GetEventColor());
 }
Exemple #17
0
 public Color GetEventColor(string str)
 {
     return(FGUI.GetEventColor());
 }
Exemple #18
0
 protected virtual Color GetPreviewIconColor()
 {
     return(FGUI.GetIconColor());
 }
Exemple #19
0
        private void AddContainer()
        {
            GenericMenu menu = new GenericMenu();

            bool hasDefaultContainers = false;

            List <FColorSetting> defaultContainers = FUtility.GetSettings().DefaultContainers;

            foreach (FColorSetting colorSetting in defaultContainers)
            {
                if (string.IsNullOrEmpty(colorSetting._str))
                {
                    continue;
                }

                menu.AddItem(new GUIContent(colorSetting._str), false, CreateContainer, colorSetting);
                hasDefaultContainers = true;
            }

            if (!hasDefaultContainers)
            {
                _sequenceWindow.GetSequenceEditor().CreateContainer(new FColorSetting("Default", FGUI.DefaultContainerColor()));
                return;
            }

            menu.AddSeparator(null);

            menu.AddItem(new GUIContent("[Default New Container]"), false, CreateContainer, new FColorSetting("Default", FGUI.DefaultContainerColor()));

            menu.ShowAsContext();
        }
Exemple #20
0
        protected virtual void RenderHeader(Rect headerRect, float headerWidth)
        {
            if (HeaderHeight == 0)
            {
                return;
            }

            if (Event.current.type == EventType.Repaint)
            {
                GUI.color = BackgroundColor;
                EditorGUI.DrawTextureAlpha(headerRect, EditorGUIUtility.whiteTexture);
                GUI.color = Color.white;
            }

            Rect foldoutRect = headerRect;

            foldoutRect.width = 16;

            GUI.backgroundColor = Color.white;
            EditorGUI.BeginChangeCheck();
            ShowEditorList = EditorGUI.Foldout(foldoutRect, ShowEditorList, string.Empty);
            if (EditorGUI.EndChangeCheck())
            {
                if (Event.current.shift)
                {
                    if (this is FContainerEditor)
                    {
                        ShowAllContainers(ShowEditorList);
                    }
                    else if (this is FTimelineEditor)
                    {
                        ShowAllTimelines(ShowEditorList);
                    }
                }
            }

            Rect labelRect = headerRect;

            labelRect.width = headerWidth;
            labelRect.xMin += 16;

            Rect iconRect = labelRect;

            if (_icon != null)
            {
                if (IconOnLeft)
                {
                    labelRect.xMin += IconSize;
                }
                else
                {
                    labelRect.xMax -= IconSize;
                    iconRect.xMin   = labelRect.xMax;
                }

                iconRect.width  = IconSize;
                iconRect.height = IconSize;

                GUI.color = FGUI.GetIconColor();
                GUI.DrawTexture(iconRect, _icon.image);
                GUI.color = Color.white;
            }

            GUI.contentColor = FGUI.GetTextColor();
            GUI.Label(labelRect, HeaderText, EditorStyles.boldLabel);

            OnHeaderInput(labelRect, iconRect);
        }
Exemple #21
0
        public override void OnInspectorGUI()
        {
            GUIStyle centeredLabel = new GUIStyle(EditorStyles.largeLabel);

            centeredLabel.alignment = TextAnchor.MiddleCenter;
            GUILayout.Label("Flux Color Settings", centeredLabel);

            EditorGUI.BeginChangeCheck();

            RenderColorList("Event Colors", _fluxSettings.EventColors, "<Flux.EventType>", FGUI.GetEventColor(), EVENT_COLOR_MSG);

            GUILayout.Space(10);

            RenderColorList("Default Containers", _fluxSettings.DefaultContainers, "<Container Name>", Flux.FContainer.DEFAULT_COLOR, CONTAINER_COLOR_MSG);

            foreach (var item in _fluxSettings.ContainerType)
            {
                GUILayout.Space(10);
                RenderContainerList(item._name, item._list);
            }

            if (EditorGUI.EndChangeCheck())
            {
                RebuildSettingsCache();
            }
        }
//		private float _speed = 1f;
//
//		public float Speed
//		{
//			set
//			{
//				_speed = value;
//
//				_speedIndex = 0;
////				float distance = float.MaxValue;
//				for( int i = 1; i != _speedValues.Length; ++i )
//				{
//					if( Mathf.Approximately( _speed, _speedValues[i] ) )
//					{
//						_speedIndex = i;
//						break;
//					}
////					if( Mathf.Abs( speed - _speedValues[i] ) < distance )
////					{
////						distance = Mathf.Abs( speed - _speedValues[i] );
////						_speedIndex = i;
////					}
//				}
//
//				if( _speedIndex > 0 )
//					_window.GetSequenceEditor().GetSequence().Speed = _speedValues[_speedIndex] * (_window.GetSequenceEditor().IsPlayingForward ? 1f : -1f);
//				else
//					_speedValueStrs[0].text = _speed.ToString("0.00")+'x';
//			}
//		}

        public void OnGUI()
        {
            FSequence  sequence  = _window.GetSequenceEditor().Sequence;
            FrameRange viewRange = _window.GetSequenceEditor().ViewRange;

            GUI.backgroundColor = Color.white;
            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.CurrentFrame - 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.CurrentFrame < 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.CurrentFrame, numberFieldStyle), 0, sequence.Length);
                    if (EditorGUI.EndChangeCheck())
                    {
                        _window.GetSequenceEditor().SetCurrentFrame(newCurrentFrame);
                    }
                }
            }

            if (GUI.Button(_nextFrameButtonRect, _nextFrame, EditorStyles.miniButtonMid) || goToNext)
            {
                GoToFrame(viewRange.Cull(sequence.CurrentFrame + 1));
            }

            if (GUI.Button(_lastFrameButtonRect, _lastFrame, EditorStyles.miniButtonRight) || goToLast)
            {
                GoToFrame(viewRange.End);
            }

//			if( GUI.Button( _playBackwardButtonRect, isPlaying ? _pause : _playBackward, EditorStyles.miniButtonLeft ) )
//			{
//				if( isPlaying )
//					Pause();
//				else
//					PlayBackwards();
//			}

            if (GUI.Button(_stopButtonRect, _stop, EditorStyles.miniButtonLeft))
            {
                Stop();
            }

            if (Event.current.type == EventType.MouseUp && _playForwardButtonRect.Contains(Event.current.mousePosition))
            {
                _window.GetSequenceEditor().IsPlayingForward = Event.current.button == 0;
            }

            bool isPlaying        = Application.isPlaying ? _window.GetSequenceEditor().Sequence.IsPlaying : _window.GetSequenceEditor().IsPlaying;
            bool isPlayingForward = _window.GetSequenceEditor().IsPlayingForward;

            if (GUI.Button(_playForwardButtonRect, isPlaying ? _pause : (isPlayingForward ? _playForward : _playBackward), EditorStyles.miniButtonRight))
            {
                if (isPlaying)
                {
                    Pause();
                }
                else if (isPlayingForward)
                {
                    Play();
                }
                else
                {
                    PlayBackwards();
                }
            }

            if (_showSpeedSlider)
            {
                GUI.Label(_speedLabelRect, _speedLabel);

                float currentSpeed = Mathf.Abs(_window.GetSequenceEditor().Sequence.Speed);
                EditorGUI.BeginChangeCheck();
                float speed = GUI.HorizontalSlider(_speedSliderRect, currentSpeed, _speedValues[0], _speedValues[_speedValues.Length - 1]);
                if (EditorGUI.EndChangeCheck())
                {
                    int   speedIndex = 0;
                    float distance   = float.MaxValue;
                    for (int i = 0; i != _speedValues.Length; ++i)
                    {
                        if (Mathf.Abs(speed - _speedValues[i]) < distance)
                        {
                            distance   = Mathf.Abs(speed - _speedValues[i]);
                            speedIndex = i;
                        }
                    }
//					Speed = _speedValues[_speedIndex];
                    _window.GetSequenceEditor().Sequence.Speed = _speedValues[speedIndex] * (isPlayingForward ? 1f : -1f);
                }
//				if( !Mathf.Approximately(speed, currentSpeed) )
//				{
//					_speedIndex = 0;
//					float distance = float.MaxValue;
//					for( int i = 0; i != _speedValues.Length; ++i )
//					{
//						if( Mathf.Abs( speed - _speedValues[i] ) < distance )
//						{
//							distance = Mathf.Abs( speed - _speedValues[i] );
//							_speedIndex = i;
//						}
//					}
//					_window.GetSequenceEditor().GetSequence().Speed = _speedValues[_speedIndex] * (isPlayingForward ? 1f : -1f);
//				}

//				GUI.Label( _speedValueRect, _speedValueStrs[_speedIndex] );
                EditorGUI.BeginChangeCheck();
                speed = Mathf.Abs(EditorGUI.FloatField(_speedValueRect, currentSpeed));
                if (EditorGUI.EndChangeCheck())
                {
                    _window.GetSequenceEditor().Sequence.Speed = speed * (isPlayingForward ? 1f : -1f);
                }
            }

            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);
                }
            }
        }
Exemple #23
0
        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);
                }
            }
        }
Exemple #24
0
        public static int TimeScrubber(Rect rect, int t, int frameRate, FrameRange range)
        {
            //		Rect actualRect = rect;
            //		actualRect.xMax -= 20; // buffer on the right

            Rect clickRect = rect;

            clickRect.yMin = clickRect.yMax - TIMELINE_SCRUBBER_HEIGHT;

            int length = range.Length;

            int controlId = EditorGUIUtility.GetControlID(FocusType.Passive);

            switch (Event.current.type)
            {
            case EventType.Repaint:
                int frames = range.Start;

                float width = rect.width;

                int maxFramesBetweenSteps = Mathf.Max(1, Mathf.FloorToInt(width / MIN_PIXELS_BETWEEN_FRAMES));

                int numFramesPerStep = Mathf.Max(1, length / maxFramesBetweenSteps);

                // multiple of 60 fps?
                if (numFramesPerStep < 30)
                {
                    if (numFramesPerStep <= 12)
                    {
                        if (numFramesPerStep != 5)
                        {
                            if (12 % numFramesPerStep != 0)
                            {
                                numFramesPerStep = 12;
                            }
                        }
                    }
                    else
                    {
                        numFramesPerStep = 30;
                    }
                }
                else if (numFramesPerStep < 60)
                {
                    numFramesPerStep = 60;
                }
                else
                {
                    int multiplesOf60 = numFramesPerStep / 60;
                    numFramesPerStep = (multiplesOf60 + 1) * 60;
                }

                int numFramesIter = numFramesPerStep < 30 ? 1 : numFramesPerStep / 10;

                Vector3 pt = new Vector3(rect.x, rect.yMax - TIMELINE_SCRUBBER_TEXT_HEIGHT, 0);

                Rect backgroundRect = clickRect;
                backgroundRect.xMin  = 0;
                backgroundRect.xMax += FSequenceEditor.RIGHT_BORDER;

//				GUI.color = new Color( 0.15f, 0.15f, 0.15f, 1f );//FGUI.GetTimelineColor();
//				GUI.DrawTexture( backgroundRect, EditorGUIUtility.whiteTexture );
//				GUI.color = Color.white;
                GUI.color = GetTextColor();                 // a little darker than it is originally to stand out
                GUI.Label(backgroundRect, GUIContent.none, FGUI.GetTimeScrubberStyle());

                Handles.color = GetLineColor();

                //			int framesBetweenSteps = maxFramesBetweenSteps / (maxFramesBetweenSteps * 10 / MIN_PIXELS_BETWEEN_FRAMES);
                //			float pixelsBetweenSteps = minPixelsBetweenSteps / framesBetweenSteps;
                //
                //			Debug.Log ( maxFramesBetweenSteps + " " + minPixelsBetweenSteps + " vs " + framesBetweenSteps + " " + pixelsBetweenSteps );

                GUIStyle labelStyle = new GUIStyle(EditorStyles.boldLabel);
                labelStyle.normal.textColor = Color.white;
                labelStyle.alignment        = TextAnchor.UpperCenter;

                GUI.contentColor = FGUI.GetLineColor();

                frames = (frames / numFramesIter) * numFramesIter;
                while (frames <= range.End)
                {
                    pt.x = rect.x + (width * ((float)(frames - range.Start) / length));

                    if (pt.x >= rect.x)
                    {
                        if (frames % numFramesPerStep == 0)
                        {
                            Handles.DrawLine(pt, pt - new Vector3(0, rect.height - TIMELINE_SCRUBBER_TEXT_HEIGHT, 0));

                            GUI.Label(new Rect(pt.x - 30, pt.y, 60, TIMELINE_SCRUBBER_TEXT_HEIGHT), FUtility.GetTime(frames, frameRate), labelStyle);
                        }
                        else
                        {
                            Vector3 smallTickPt = pt;
                            smallTickPt.y -= TIMELINE_SCRUBBER_TICK_HEIGHT;
                            Handles.DrawLine(smallTickPt, smallTickPt - new Vector3(0, TIMELINE_SCRUBBER_TICK_HEIGHT, 0));
                        }
                    }

                    frames += numFramesIter;
                }

                if (t >= 0 && range.Contains(t))
                {
                    Vector3 tStart = new Vector3(rect.x + (width * ((float)(t - range.Start) / length)), rect.yMin, 0);
                    Vector3 tEnd   = tStart;
                    tEnd.y = rect.yMax - TIMELINE_SCRUBBER_TEXT_HEIGHT;

                    Handles.color = Color.red;
                    Handles.DrawLine(tStart, tEnd);

                    GUI.contentColor = Color.red;
                    GUI.Label(new Rect(tEnd.x - 30, tEnd.y, 60, TIMELINE_SCRUBBER_TEXT_HEIGHT), FUtility.GetTime(t, frameRate), labelStyle);
                    GUI.contentColor = FGUI.GetTextColor();
                }

                GUI.color        = Color.white;
                GUI.contentColor = Color.white;

                Handles.color = GetLineColor();

                Handles.DrawLine(new Vector3(rect.x, rect.yMin, 0), new Vector3(rect.x, rect.yMax - TIMELINE_SCRUBBER_HEIGHT, 0));

                break;

            case EventType.MouseDown:
                if (EditorGUIUtility.hotControl == 0 && clickRect.Contains(Event.current.mousePosition))
                {
                    EditorGUIUtility.hotControl = controlId;
                }
                goto case EventType.MouseDrag;

            case EventType.MouseDrag:
                if (EditorGUIUtility.hotControl == controlId)
                {
                    Rect touchRect = rect;
                    touchRect.yMin = touchRect.yMax - TIMELINE_SCRUBBER_HEIGHT;
                    //			if( touchRect.Contains( Event.current.mousePosition ) )
                    {
                        //				Debug.Log( (Event.current.mousePosition.x - touchRect.xMin /
                        t = Mathf.Clamp(range.Start + Mathf.RoundToInt(((Event.current.mousePosition.x - touchRect.xMin) / touchRect.width) * range.Length), range.Start, range.End);
                        Event.current.Use();
                    }
                }
                break;

            case EventType.MouseUp:
                if (EditorGUIUtility.hotControl == controlId)
                {
                    EditorGUIUtility.hotControl = 0;
                    Event.current.Use();
                }
                break;
            }
            rect.height = TIMELINE_SCRUBBER_HEIGHT;

            return(t);
        }
        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;
        }