示例#1
0
        public override void OnInspectorGUI()
        {
            //		EditorGUILayout.PropertyField( _script );

            if (_allEventsSameType)
            {
                serializedObject.Update();
                EditorGUILayout.PropertyField(_triggerOnSkip, new GUIContent("跳过触发器"));
            }
            else
            {
                bool triggerOnSkipMatch = true;

                for (int i = 0; i != targets.Length; ++i)
                {
                    if (((FEvent)targets[i]).TriggerOnSkip != _evt.TriggerOnSkip)
                    {
                        triggerOnSkipMatch = false;
                        break;
                    }
                }

                EditorGUI.BeginChangeCheck();
                bool triggerOnSkip = EditorGUILayout.Toggle("跳过触发器", _evt.TriggerOnSkip, triggerOnSkipMatch ? EditorStyles.toggle : "ToggleMixed");
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObjects(targets, " Inspector");
                    for (int i = 0; i != targets.Length; ++i)
                    {
                        FEvent evt = (FEvent)targets[i];
                        evt.TriggerOnSkip = triggerOnSkip;
                    }
                }
            }

            //        EditorGUILayout.IntField( "Instance ID", _evt.GetInstanceID() );

            FrameRange validRange = _evt.Track != null?_evt.Track.GetValidRange(_evt) : new FrameRange(_evt.Start, _evt.End);

            if (!_isSingleFrame)
            {
                float startFrame = _evt.Start;
                float endFrame   = _evt.End;
                EditorGUI.BeginChangeCheck();

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.PrefixLabel("范围");
                GUILayout.Label("开始:", EditorStyles.label);
                GUI.SetNextControlName(FRAMERANGE_START_FIELD_ID);
                startFrame = EditorGUILayout.IntField(_evt.Start);
                GUILayout.Label("结束:", EditorStyles.label);
                endFrame = EditorGUILayout.IntField(_evt.End);
                EditorGUILayout.EndHorizontal();


                if (EditorGUI.EndChangeCheck())
                {
                    bool changedStart = GUI.GetNameOfFocusedControl() == FRAMERANGE_START_FIELD_ID;

                    for (int i = 0; i != targets.Length; ++i)
                    {
                        FEvent evt = (FEvent)targets[i];

                        FrameRange newFrameRange = evt.FrameRange;
                        if (changedStart)
                        {
                            if (startFrame <= newFrameRange.End)
                            {
                                newFrameRange.Start = (int)startFrame;
                            }
                        }
                        else if (endFrame >= newFrameRange.Start)
                        {
                            newFrameRange.End = (int)endFrame;
                        }

                        if (newFrameRange.Length >= evt.GetMinLength() && newFrameRange.Length <= evt.GetMaxLength())
                        {
                            FSequenceEditorWindow.instance.GetSequenceEditor().MoveEvent(evt, newFrameRange);
                            FEventEditor.FinishMovingEventEditors();
                            //						FUtility.Resize( evt, newFrameRange );
                        }
                    }
                }

                if (targets.Length == 1)
                {
                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.BeginHorizontal();
                    GUILayout.Space(EditorGUIUtility.labelWidth);
                    float sliderStartFrame = startFrame;
                    float sliderEndFrame   = endFrame;
                    EditorGUILayout.MinMaxSlider(ref sliderStartFrame, ref sliderEndFrame, validRange.Start, validRange.End);
                    EditorGUILayout.EndHorizontal();
                    if (EditorGUI.EndChangeCheck())
                    {
                        FrameRange newFrameRange = new FrameRange((int)sliderStartFrame, (int)sliderEndFrame);
                        if (newFrameRange.Length < _evt.GetMinLength())
                        {
                            if (sliderStartFrame != startFrame) // changed start
                            {
                                newFrameRange.Start = newFrameRange.End - _evt.GetMinLength();
                            }
                            else
                            {
                                newFrameRange.Length = _evt.GetMinLength();
                            }
                        }

                        //					FUtility.Resize( _evt, newFrameRange );
                        FSequenceEditorWindow.instance.GetSequenceEditor().MoveEvent(_evt, newFrameRange);
                        FEventEditor.FinishMovingEventEditors();
                    }
                }
            }
            else
            {
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.IntSlider(_singleFrame, validRange.Start + 1, validRange.End, _singleFrameUI);
                if (EditorGUI.EndChangeCheck())
                {
                    _evt.SingleFrame = _singleFrame.intValue;
                    FrameRange newFrameRange = _evt.FrameRange;
                    newFrameRange.Start = _evt.SingleFrame - 1;
                    newFrameRange.End   = _evt.SingleFrame;
                    FSequenceEditorWindow.instance.GetSequenceEditor().MoveEvent(_evt, newFrameRange);
                    FEventEditor.FinishMovingEventEditors();
                }
            }


            if (_allEventsSameType)
            {
                serializedObject.ApplyModifiedProperties();
                base.OnInspectorGUI();

                serializedObject.Update();
                foreach (var field in _fields)
                {
                    if (field.AddFindBtn)
                    {
                        EditorGUILayout.BeginHorizontal();
                        EditorGUILayout.PropertyField(field.Property, field.DisplayName);
                        if (GUILayout.Button("F", GUILayout.Width(30)))
                        {
                            UnityEngine.Object obj  = Selection.activeObject;
                            string             path = AssetDatabase.GetAssetPath(obj);
                            if (obj != null && string.IsNullOrEmpty(path))
                            {
                                path = GetSceneNodePath((obj as GameObject).transform);
                                field.Property.stringValue = path;
                            }
                            else if (!string.IsNullOrEmpty(path))
                            {
                                field.Property.stringValue = path;
                            }
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                    else
                    {
                        EditorGUILayout.PropertyField(field.Property, field.DisplayName);
                    }
                }
                serializedObject.ApplyModifiedProperties();
            }
        }
        public override void OnInspectorGUI()
        {
            float startFrame = _evt.Start;
            float endFrame   = _evt.End;

            FrameRange validRange = _evt.Track != null?_evt.Track.GetValidRange(_evt) : new FrameRange(_evt.Start, _evt.End);

            EditorGUI.BeginChangeCheck();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Range");
            GUILayout.Label("S:", EditorStyles.label);
            GUI.SetNextControlName(FRAMERANGE_START_FIELD_ID);
            startFrame = EditorGUILayout.IntField(_evt.Start);
            GUILayout.Label("E:", EditorStyles.label);
            endFrame = EditorGUILayout.IntField(_evt.End);
            EditorGUILayout.EndHorizontal();

            if (EditorGUI.EndChangeCheck())
            {
                bool changedStart = GUI.GetNameOfFocusedControl() == FRAMERANGE_START_FIELD_ID;

                for (int i = 0; i != targets.Length; ++i)
                {
                    FEvent evt = (FEvent)targets[i];

                    FrameRange newFrameRange = evt.FrameRange;
                    if (changedStart)
                    {
                        if (startFrame <= newFrameRange.End)
                        {
                            newFrameRange.Start = (int)startFrame;
                        }
                    }
                    else if (endFrame >= newFrameRange.Start)
                    {
                        newFrameRange.End = (int)endFrame;
                    }

                    if (newFrameRange.Length >= evt.GetMinLength() && newFrameRange.Length <= evt.GetMaxLength())
                    {
                        FSequenceEditorWindow.instance.GetSequenceEditor().MoveEvent(evt, newFrameRange);
                        FEventEditor.FinishMovingEventEditors();
                    }
                }
            }

            if (targets.Length == 1)
            {
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.BeginHorizontal();
                GUILayout.Space(EditorGUIUtility.labelWidth);
                float sliderStartFrame = startFrame;
                float sliderEndFrame   = endFrame;
                EditorGUILayout.MinMaxSlider(ref sliderStartFrame, ref sliderEndFrame, validRange.Start, validRange.End);
                EditorGUILayout.EndHorizontal();
                if (EditorGUI.EndChangeCheck())
                {
                    FrameRange newFrameRange = new FrameRange((int)sliderStartFrame, (int)sliderEndFrame);
                    if (newFrameRange.Length < _evt.GetMinLength())
                    {
                        if (sliderStartFrame != startFrame)                          // changed start
                        {
                            newFrameRange.Start = newFrameRange.End - _evt.GetMinLength();
                        }
                        else
                        {
                            newFrameRange.Length = _evt.GetMinLength();
                        }
                    }

                    FSequenceEditorWindow.instance.GetSequenceEditor().MoveEvent(_evt, newFrameRange);
                    FEventEditor.FinishMovingEventEditors();
                }
            }


            if (_allEventsSameType)
            {
                serializedObject.ApplyModifiedProperties();
                base.OnInspectorGUI();
            }
        }
示例#3
0
        public override void OnInspectorGUI()
        {
            //		EditorGUILayout.PropertyField( _script );

            if (_allEventsSameType)
            {
                serializedObject.Update();
                EditorGUILayout.PropertyField(_triggerOnSkip);
            }
            else
            {
                bool triggerOnSkipMatch = true;

                for (int i = 0; i != targets.Length; ++i)
                {
                    if (((FEvent)targets[i]).TriggerOnSkip != _evt.TriggerOnSkip)
                    {
                        triggerOnSkipMatch = false;
                        break;
                    }
                }

                EditorGUI.BeginChangeCheck();
                bool triggerOnSkip = EditorGUILayout.Toggle("Trigger On Skip", _evt.TriggerOnSkip, triggerOnSkipMatch ? EditorStyles.toggle : "ToggleMixed");
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObjects(targets, " Inspector");
                    for (int i = 0; i != targets.Length; ++i)
                    {
                        FEvent evt = (FEvent)targets[i];
                        evt.TriggerOnSkip = triggerOnSkip;
                    }
                }
            }

            //        EditorGUILayout.IntField( "Instance ID", _evt.GetInstanceID() );

            float startFrame = _evt.Start;
            float endFrame   = _evt.End;

            FrameRange validRange = _evt.Track.GetValidRange(_evt);

            EditorGUI.BeginChangeCheck();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Range");
            GUILayout.Label("S:", EditorStyles.label);
            GUI.SetNextControlName(FRAMERANGE_START_FIELD_ID);
            startFrame = EditorGUILayout.IntField(_evt.Start);
            GUILayout.Label("E:", EditorStyles.label);
            endFrame = EditorGUILayout.IntField(_evt.End);
            EditorGUILayout.EndHorizontal();

            if (EditorGUI.EndChangeCheck())
            {
                bool changedStart = GUI.GetNameOfFocusedControl() == FRAMERANGE_START_FIELD_ID;

                for (int i = 0; i != targets.Length; ++i)
                {
                    FEvent evt = (FEvent)targets[i];

                    FrameRange newFrameRange = evt.FrameRange;
                    if (changedStart)
                    {
                        if (startFrame <= newFrameRange.End)
                        {
                            newFrameRange.Start = (int)startFrame;
                        }
                    }
                    else if (endFrame >= newFrameRange.Start)
                    {
                        newFrameRange.End = (int)endFrame;
                    }

                    if (newFrameRange.Length >= evt.GetMinLength() && newFrameRange.Length <= evt.GetMaxLength())
                    {
                        FSequenceEditorWindow.instance.GetSequenceEditor().MoveEvent(evt, newFrameRange);
                        FEventEditor.FinishMovingEventEditors();
//						FUtility.Resize( evt, newFrameRange );
                    }
                }
            }

            if (targets.Length == 1)
            {
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.BeginHorizontal();
                GUILayout.Space(EditorGUIUtility.labelWidth);
                float sliderStartFrame = startFrame;
                float sliderEndFrame   = endFrame;
                EditorGUILayout.MinMaxSlider(ref sliderStartFrame, ref sliderEndFrame, validRange.Start, validRange.End);
                EditorGUILayout.EndHorizontal();
                if (EditorGUI.EndChangeCheck())
                {
                    FrameRange newFrameRange = new FrameRange((int)sliderStartFrame, (int)sliderEndFrame);
                    if (newFrameRange.Length < _evt.GetMinLength())
                    {
                        if (sliderStartFrame != startFrame)                          // changed start
                        {
                            newFrameRange.Start = newFrameRange.End - _evt.GetMinLength();
                        }
                        else
                        {
                            newFrameRange.Length = _evt.GetMinLength();
                        }
                    }

//					FUtility.Resize( _evt, newFrameRange );
                    FSequenceEditorWindow.instance.GetSequenceEditor().MoveEvent(_evt, newFrameRange);
                    FEventEditor.FinishMovingEventEditors();
                }
            }


            if (_allEventsSameType)
            {
                serializedObject.ApplyModifiedProperties();
                base.OnInspectorGUI();
            }
        }