Ejemplo n.º 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;
        }
Ejemplo n.º 2
0
        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();
        }
Ejemplo n.º 3
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;
        }