public static EventEditorGUI CreateEventEditorGUI(TimelineEditor editor, Event evnt)
                {
                    if (_editorGUIConstructorMap == null)
                    {
                        _editorGUIConstructorMap = new Dictionary <Type, Type>();
                        Type[] types = SystemUtils.GetAllSubTypes(typeof(EventEditorGUI));

                        foreach (Type type in types)
                        {
                            EventCustomEditorGUIAttribute eventAttribute = SystemUtils.GetAttribute <EventCustomEditorGUIAttribute>(type);
                            if (eventAttribute != null)
                            {
                                _editorGUIConstructorMap.Add(eventAttribute.EventType, type);
                            }
                        }
                    }

                    //Check for custom editor class
                    Type editorGUIType;

                    if (!_editorGUIConstructorMap.TryGetValue(evnt.GetType(), out editorGUIType))
                    {
                        //Use generic editor gui class
                        editorGUIType = typeof(EventEditorGUI);
                    }

                    EventEditorGUI editorGUI = (EventEditorGUI)EventEditorGUI.CreateInstance(editorGUIType);

                    editorGUI.Init(editor, evnt);

                    return(editorGUI);
                }
예제 #2
0
                private void RenderEventArrow(EventEditorGUI evnt, bool selected)
                {
                    if (_timelineArea.IsTimeVisible(evnt.GetTime()))
                    {
                        float position = _timelineArea.GetPosition(evnt.GetTime());
                        float xPos     = Mathf.Floor(position) + 0.5f;

                        Handles.BeginGUI();

                        //Draw arrow head / pin
                        {
                            if (selected)
                            {
                                Handles.color = Color.white;

                                Handles.DrawSolidDisc(new Vector3(xPos, evnt.GetBounds().yMax + kPinWidth, 0.0f), -Vector3.forward, 4.24f);

                                Handles.DrawAAConvexPolygon(new Vector3(xPos, 0f, 0.0f),
                                                            new Vector3(xPos + kArrowWidth + 2f, 2f + kArrowHeight, 0.0f),
                                                            new Vector3(xPos - kArrowWidth - 2f, 2f + kArrowHeight, 0.0f));

                                Handles.color = evnt.GetColor();

                                Handles.DrawSolidDisc(new Vector3(xPos, evnt.GetBounds().yMax + kPinWidth, 0.0f), -Vector3.forward, kPinWidth);

                                Handles.DrawAAConvexPolygon(new Vector3(xPos, 1.5f, 0.0f),
                                                            new Vector3(xPos + kArrowWidth, 1 + kArrowHeight, 0.0f),
                                                            new Vector3(xPos - kArrowWidth, 1 + kArrowHeight, 0.0f));
                            }
                            else
                            {
                                Handles.color = evnt.GetColor();
                                Handles.DrawSolidDisc(new Vector3(xPos, evnt.GetBounds().yMax + kPinWidth, 0.0f), -Vector3.forward, kPinWidth);

                                Handles.DrawAAConvexPolygon(new Vector3(xPos, 0, 0.0f),
                                                            new Vector3(xPos + kArrowWidth, 0 + kArrowHeight, 0.0f),
                                                            new Vector3(xPos - kArrowWidth, 0 + kArrowHeight, 0.0f));
                            }
                        }

                        Handles.color = evnt.GetColor();
                        Handles.DrawPolyLine(new Vector3(xPos, kArrowHeight), new Vector3(xPos, evnt.GetBounds().yMax + 0.5f));

                        if (selected)
                        {
                            Handles.color = Color.white;
                            Handles.DrawPolyLine(new Vector3(xPos - 1, kArrowHeight + 2), new Vector3(xPos - 1, evnt.GetBounds().yMax + 0.5f));
                            Handles.DrawPolyLine(new Vector3(xPos - 2, kArrowHeight + 2), new Vector3(xPos - 2, evnt.GetBounds().yMax + 0.5f));

                            Handles.DrawPolyLine(new Vector3(xPos + 1, kArrowHeight + 2), new Vector3(xPos + 1, evnt.GetBounds().yMin + EventEditorGUI.kDurationBoxY + 0.5f));
                            Handles.DrawPolyLine(new Vector3(xPos + 2, kArrowHeight + 2), new Vector3(xPos + 2, evnt.GetBounds().yMin + EventEditorGUI.kDurationBoxY + 0.5f));

                            Handles.DrawPolyLine(new Vector3(xPos + 1, evnt.GetBounds().yMax - EventEditorGUI.kShadowSize - 0.5f), new Vector3(xPos + 1, evnt.GetBounds().yMax + 0.5f));
                            Handles.DrawPolyLine(new Vector3(xPos + 2, evnt.GetBounds().yMax - EventEditorGUI.kShadowSize - 0.5f), new Vector3(xPos + 2, evnt.GetBounds().yMax + 0.5f));
                        }

                        Handles.EndGUI();
                    }
                }
                public override int CompareTo(object obj)
                {
                    EventEditorGUI evnt = obj as EventEditorGUI;

                    if (evnt == null)
                    {
                        return(1);
                    }

                    if (evnt == this)
                    {
                        return(0);
                    }

                    return(this.GetEditableObject().CompareTo(evnt.GetEditableObject()));
                }
예제 #4
0
                public void SetEventTime(EventEditorGUI evnt, float time)
                {
                    time = Mathf.Max(time, 0.0f);

                    if (evnt.EndsTimeline())
                    {
                        foreach (EventEditorGUI evt in _editableObjects)
                        {
                            if (!evt.EndsTimeline())
                            {
                                time = Math.Max(time, evt.GetTime() + evt.GetDuration());
                            }
                        }
                    }

                    evnt.SetTime(time);
                    evnt.MarkAsDirty(true);
                }
예제 #5
0
 protected override SerializedObjectEditorGUI <Event> CreateObjectEditorGUI(Event evnt)
 {
     return(EventEditorGUI.CreateEventEditorGUI(this, evnt));
 }