Beispiel #1
0
//		public void SetTimelineEditors( List<CTimelineEditor> timelineEditors )
//		{
//			_timelineEditors = timelineEditors;
//		}

        public void AddEvent(int t)
        {
            List <ISelectableElement> newEvents = new List <ISelectableElement>();

            foreach (FTimelineEditor timelineEditor in _timelineEditors)
            {
                foreach (FTrackEditor trackEditor in timelineEditor._trackEditors)
                {
                    if (!trackEditor.IsSelected())
                    {
                        continue;
                    }
                    FEvent evt = trackEditor.TryAddEvent(t);
                    if (evt)
                    {
                        FEventEditor evtEditor = GetEditor <FEventEditor>(evt);
                        evtEditor.Init(evt, trackEditor);
                        newEvents.Add(evtEditor);
                    }
                }
            }
            if (newEvents.Count > 0)
            {
                DeselectAll();
                Select(newEvents);
            }
            else
            {
                EditorApplication.Beep();
            }
        }
 private static void AddEventEditorBeingMoved(FEventEditor evtEditor, FrameRange oldFrameRange)
 {
     if (!_eventEditorsBeingMoved.ContainsKey(evtEditor))
     {
         _eventEditorsBeingMoved.Add(evtEditor, oldFrameRange);
     }
 }
Beispiel #3
0
        public FrameRange GetValidRange(FEventEditor evtEditor)
        {
            int index = 0;

            for ( ; index < _eventEditors.Count; ++index)
            {
                if (_eventEditors[index] == evtEditor)
                {
                    break;
                }
            }

            FrameRange range = new FrameRange(0, SequenceEditor.Sequence.Length);

            if (index > 0)
            {
                range.Start = _eventEditors[index - 1].Evt.End + 1;
            }
            if (index < _eventEditors.Count - 1)
            {
                range.End = _eventEditors[index + 1].Evt.Start - 1;
            }

            return(range);
        }
Beispiel #4
0
        private void DeselectEvent(FEventEditor eventEditor)
        {
            if (eventEditor == null || !eventEditor.IsSelected())
            {
                return;
            }

            Undo.RegisterCompleteObjectUndo(new Object[] { eventEditor, this }, "deselect Event");

            _selectedEvents.Remove(eventEditor);
            FInspectorWindow.SetEvents(_selectedEvents);

            eventEditor.OnDeselect();
        }
Beispiel #5
0
        private void SelectEvent(FEventEditor eventEditor)
        {
            if (eventEditor == null || eventEditor.IsSelected())
            {
                return;
            }

            SelectTrack(eventEditor._trackEditor);
            Undo.RegisterCompleteObjectUndo(new Object[] { eventEditor, this }, "select Event");

            _selectedEvents.Add(eventEditor);
            FInspectorWindow.SetEvents(_selectedEvents);

            eventEditor.OnSelect();
        }
Beispiel #6
0
        public override void Init(FObject obj, FEditor owner)
        {
            base.Init(obj, owner);

            _eventEditors.Clear();

            List <FEvent> events = Track.Events;

            for (int i = 0; i < events.Count; ++i)
            {
                FEvent       evt       = events[i];
                FEventEditor evtEditor = SequenceEditor.GetEditor <FEventEditor>(evt);
                evtEditor.Init(evt, this);
                _eventEditors.Add(evtEditor);
            }
        }
Beispiel #7
0
        protected override void Init(FObject obj)
        {
            _track = (FTrack)obj;

            _eventEditors.Clear();

            List <FEvent> events = _track.GetEvents();

            for (int i = 0; i < events.Count; ++i)
            {
                FEvent       evt       = events[i];
                FEventEditor evtEditor = SequenceEditor.GetEditor <FEventEditor>(evt);
                evtEditor.Init(evt, this);
                _eventEditors.Add(evtEditor);
            }
        }
Beispiel #8
0
        public override void Init(FObject obj, FEditor owner)
        {
            bool initForFirstTime = Track == null;

            base.Init(obj, owner);

            _eventEditors.Clear();

            List <FEvent> events = Track.Events;

            for (int i = 0; i < events.Count; ++i)
            {
                FEvent       evt       = events[i];
                FEventEditor evtEditor = SequenceEditor.GetEditor <FEventEditor>(evt);
                evtEditor.Init(evt, this);
                _eventEditors.Add(evtEditor);
            }

            if (initForFirstTime && Track.PreviewDirtiesScene)
            {
                Track.CanPreview = false;
            }
        }
Beispiel #9
0
        public void MoveEvents(int deltaFrames)
        {
            bool movingLeft = deltaFrames < 0;

            int howMuchCanMove = int.MaxValue;

            for (int i = 0; i != _selectedTracks.Count; ++i)
            {
                if (movingLeft)
                {
                    for (int j = 0; j != _selectedTracks[i]._eventEditors.Count; ++j)
                    {
                        FEventEditor evtEditor = _selectedTracks[i]._eventEditors[j];
                        if (evtEditor.IsSelected())
                        {
                            if (j == 0)
                            {
                                howMuchCanMove = Mathf.Min(howMuchCanMove, evtEditor._evt.Start);
                            }
                            else if (!_selectedTracks[i]._eventEditors[j - 1].IsSelected())
                            {
                                howMuchCanMove = Mathf.Min(howMuchCanMove, evtEditor._evt.Start - _selectedTracks[i]._eventEditors[j - 1]._evt.End);
                            }
                        }
                    }
                }
                else
                {
                    int lastElementIndex = _selectedTracks[i]._eventEditors.Count - 1;
                    for (int j = lastElementIndex; j != -1; --j)
                    {
                        FEventEditor evtEditor = _selectedTracks[i]._eventEditors[j];
                        if (evtEditor.IsSelected())
                        {
                            if (j == lastElementIndex)
                            {
                                howMuchCanMove = Mathf.Min(howMuchCanMove, _sequence.Length - evtEditor._evt.End);
                            }
                            else if (!_selectedTracks[i]._eventEditors[j + 1].IsSelected())
                            {
                                howMuchCanMove = Mathf.Min(howMuchCanMove, _selectedTracks[i]._eventEditors[j + 1]._evt.Start - evtEditor._evt.End);
                            }
                        }
                    }
                }
            }

            if (movingLeft)
            {
                howMuchCanMove = -howMuchCanMove;
                deltaFrames    = Mathf.Clamp(deltaFrames, howMuchCanMove, 0);
            }
            else
            {
                deltaFrames = Mathf.Clamp(deltaFrames, 0, howMuchCanMove);
            }

            if (deltaFrames != 0)
            {
                for (int i = 0; i != _selectedEvents.Count; ++i)
                {
                    Undo.RecordObject(_selectedEvents[i]._evt, "move Event");
                    _selectedEvents[i]._evt.Start += deltaFrames;
                    _selectedEvents[i]._evt.End   += deltaFrames;
                    EditorUtility.SetDirty(_selectedEvents[i]._evt);
                }
            }
        }
        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();
            }
        }
Beispiel #11
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()
        {
            //		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();
            }
        }