Example #1
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;
        }
        public static void Open(FSequence sequence)
        {
            Open();

            instance._sequenceEditor.OpenSequence(sequence);
        }
Example #3
0
 public static void Upgrade(FSequence sequence)
 {
 }
        void OnEnable()
        {
            _sequence = (FSequence)target;

            _timelineContainer = serializedObject.FindProperty("_timelineContainer");
        }
        void OnGUI()
        {
#if FLUX_PROFILE
            Profiler.BeginSample("Flux OnGUI");
#endif
            if (_sequenceEditor == null)
            {
                return;
            }

            Rect currentWindowRect = position;
            currentWindowRect.x = 0;
            currentWindowRect.y = 0;

            if (currentWindowRect != _windowRect)
            {
                RebuildLayout();
            }

            if (Event.current.type == EventType.Ignore)
            {
                EditorGUIUtility.hotControl = 0;
            }

            FSequence sequence = _sequenceEditor.GetSequence();

            if (sequence == null)
            {
                ShowNotification(new GUIContent("Select Or Create Sequence"));
            }
            else if (Event.current.isKey)
            {
                if (Event.current.keyCode == KeyCode.Space)
                {
                    if (Event.current.type == EventType.KeyUp)
                    {
                        if (_sequenceEditor.IsPlaying)
                        {
                            if (Event.current.shift)
                            {
                                Stop();
                            }
                            else
                            {
                                Pause();
                            }
                        }
                        else
                        {
                            Play(Event.current.shift);
                        }


                        Repaint();
                    }
                    Event.current.Use();
                }

                if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Return)
                {
                    EditorGUIUtility.keyboardControl = 0;
                    Event.current.Use();
                    Repaint();
                }
            }


            // header
            _windowHeader.OnGUI();

            if (sequence == null)
            {
                return;
            }

            // toolbar
            _toolbar.OnGUI();

            switch (Event.current.type)
            {
            case EventType.KeyDown:
                if (Event.current.keyCode == KeyCode.Backspace || Event.current.keyCode == KeyCode.Delete)
                {
                    _sequenceEditor.DestroyEvents(_sequenceEditor._selectedEvents);
                    Event.current.Use();
                }
                else if (Event.current.keyCode == KeyCode.K && _sequenceEditor.GetSequence().GetCurrentFrame() >= 0)
                {
                    _sequenceEditor.AddEvent(_sequenceEditor.GetSequence().GetCurrentFrame());
                    Event.current.Use();
                }
                break;

            case EventType.MouseDown:
                break;

            case EventType.MouseUp:
                break;
            }

            if (Event.current.type == EventType.ValidateCommand)
            {
                Repaint();
            }

            _sequenceEditor.OnGUI();


            // because of a bug with windows editor, we have to not catch right button
            // otherwise ContextClick doesn't get called
            if (Event.current.type == EventType.MouseUp && Event.current.button != 1)
            {
                Event.current.Use();
            }

            // handle drag & drop
            if (Event.current.type == EventType.DragUpdated)
            {
                if (_windowRect.Contains(Event.current.mousePosition))
                {
                    DragAndDrop.visualMode = DragAndDropVisualMode.Link;
                    Event.current.Use();
                }
            }
            else if (Event.current.type == EventType.DragPerform)
            {
                if (_windowRect.Contains(Event.current.mousePosition))
                {
                    foreach (UnityEngine.Object obj in DragAndDrop.objectReferences)
                    {
                        if (!(obj is GameObject))
                        {
                            continue;
                        }

                        PrefabType prefabType = PrefabUtility.GetPrefabType(obj);
                        if (prefabType == PrefabType.ModelPrefab || prefabType == PrefabType.Prefab)
                        {
                            continue;
                        }

                        Undo.IncrementCurrentGroup();
                        UnityEngine.Object[] objsToSave = new UnityEngine.Object[] { sequence, this };

                        Undo.RegisterCompleteObjectUndo(objsToSave, string.Empty);

                        GameObject timelineGO = new GameObject(obj.name);

                        FTimeline timeline = timelineGO.AddComponent <Flux.FTimeline>();
                        timeline.SetOwner(((GameObject)obj).transform);
                        sequence.Add(timeline);

                        Undo.RegisterCompleteObjectUndo(objsToSave, string.Empty);
                        Undo.RegisterCreatedObjectUndo(timeline.gameObject, "create Timeline");
                        Undo.CollapseUndoOperations(Undo.GetCurrentGroup());
                    }
                    RemoveNotification();
                    Event.current.Use();
                    DragAndDrop.AcceptDrag();
                    Refresh();
                    EditorGUIUtility.ExitGUI();
                }
            }

            if (Event.current.type == EventType.Repaint)
            {
                Handles.DrawLine(new Vector3(_windowHeaderRect.xMin, _windowHeaderRect.yMax, 0), new Vector3(_windowHeaderRect.xMax - FSequenceEditor.RIGHT_BORDER, _windowHeaderRect.yMax, 0));
            }
#if FLUX_PROFILE
            Profiler.EndSample();
#endif
        }
Example #6
0
        void OnEnable()
        {
            _sequence = (FSequence)target;

            _content = serializedObject.FindProperty("_content");
        }
Example #7
0
        public void OpenSequence(FSequence sequence)
        {
#if FLUX_DEBUG
            Debug.Log("Opening sequence: " + sequence);
#endif
            if (sequence == null)
            {
                Debug.LogError("sequence == null");
                if (!object.Equals(sequence, null))
                {
                    sequence = (FSequence)EditorUtility.InstanceIDToObject(sequence.GetInstanceID());
                }
            }

            bool sequenceChanged = _sequence != sequence && (object.Equals(_sequence, null) || object.Equals(sequence, null) || _sequence.GetInstanceID() != sequence.GetInstanceID());

//			Debug.Log ("selected sequence! Changed? " + sequenceChanged );

            if (sequenceChanged)
            {
                if (_sequence != null)
                {
                    Stop();
                }
                _editorCache.Clear();
                _selectedEvents.Clear();
                _selectedTracks.Clear();
            }
            else
            {
                _editorCache.Refresh();
            }


            if (sequence != null)
            {
//				_sequenceInstanceID = sequence.GetInstanceID();
                if (_viewRange.Length == 0)
                {
                    _viewRange = new FrameRange(0, sequence.Length);
                }

                if (!EditorApplication.isPlaying)
                {
                    sequence.Rebuild();
                }

                List <FTimeline> timelines = sequence.GetTimelines();

                _timelineEditors.Clear();

                for (int i = 0; i < timelines.Count; ++i)
                {
                    FTimeline       timeline       = timelines[i];
                    FTimelineEditor timelineEditor = GetEditor <FTimelineEditor>(timeline);
                    timelineEditor.Init(timeline, this);
                    _timelineEditors.Add(timelineEditor);
                }

                if (_viewRange.Length == 0)
                {
                    _viewRange = new FrameRange(0, sequence.Length);
                }
            }
            else
            {
//				_sequenceInstanceID = int.MinValue;
            }

            _sequence = sequence;

            Repaint();
        }
 public override void Awake()
 {
     base.Awake();
     sequence = Fsm.GetOwnerDefaultTarget(sequenceGO).GetComponent <FSequence>();
 }
Example #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;
        }
        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;
        }