Пример #1
0
                public void CalcBounds(StateMachineEditorStyle style)
                {
                    GUIContent stateId = new GUIContent(GetEditableObject().GetStateIdLabel());

                    GUIStyle stateLabelStyle = style._stateIdTextStyle;
                    GUIStyle labelStyle      = GetTextStyle(style);

                    Vector2 stateIdDimensions = stateLabelStyle.CalcSize(stateId);
                    Vector2 labelDimensions   = GetLabelSize(labelStyle);

                    float areaWidth  = Mathf.Max(stateIdDimensions.x, labelDimensions.x) + kLabelPadding + kShadowSize + (kMaxBorderSize * 2.0f);
                    float areaHeight = stateIdDimensions.y + kStateSeperationSize + labelDimensions.y + kLabelBottom + kShadowSize + (kMaxBorderSize * 2.0f);

                    _rect.position = GetPosition();

                    _rect.width  = areaWidth;
                    _rect.height = areaHeight;

                    if (IsCentred())
                    {
                        _rect.x -= areaWidth * 0.5f;
                        _rect.y -= areaHeight * 0.5f;
                    }

                    _rect.x = Mathf.Round(_rect.position.x);
                    _rect.y = Mathf.Round(_rect.position.y);
                }
                public void Init(string title, IEditorWindow editorWindow, string editorPrefsTag,
                                 Type[] allowedTypes, StateMachineEditorStyle style,
                                 TimelineScrollArea.eTimeFormat timeFormat = TimelineScrollArea.eTimeFormat.Default)
                {
                    _title                    = title;
                    _editorPrefsTag           = editorPrefsTag;
                    _allowedEvents            = allowedTypes;
                    _style                    = style;
                    _timelineEditorTimeFormat = timeFormat;

                    string editorPrefsText = ProjectEditorPrefs.GetString(_editorPrefsTag, "");

                    try
                    {
                        _editorPrefs = Serializer.FromString <StateMachineEditorPrefs>(editorPrefsText);
                    }
                    catch
                    {
                        _editorPrefs = null;
                    }

                    if (_editorPrefs == null)
                    {
                        _editorPrefs = new StateMachineEditorPrefs();
                    }

                    SetEditorWindow(editorWindow);
                    CreateViews();
                }
 public override Color GetColor(StateMachineEditorStyle style)
 {
     if (GetEditableObject()._editorAutoColor)
     {
         return(style._noteColor);
     }
     else
     {
         return(GetEditableObject()._editorColor);
     }
 }
Пример #4
0
 public virtual Color GetColor(StateMachineEditorStyle style)
 {
     if (GetEditableObject()._editorAutoColor)
     {
         return(style._defaultStateColor);
     }
     else
     {
         return(GetEditableObject()._editorColor);
     }
 }
Пример #5
0
                private void CreateEditor()
                {
                    if (_stateMachineEditor == null || _stateMachineEditor.GetEditorWindow() == null)
                    {
                        StateMachineEditorStyle style = new StateMachineEditorStyle();
                        style._defaultStateColor = new Color(61f / 255f, 154f / 255f, 92f / 255f);
                        style._linkColor         = Color.white;

                        _stateMachineEditor = StateMachineEditor.CreateInstance <StateMachineEditor>();
                        _stateMachineEditor.Init(kWindowTitle, this, kWindowTag, SystemUtils.GetAllSubTypes(typeof(ITimelineStateEvent)), style);
                    }
                }
Пример #6
0
 public override Color GetColor(StateMachineEditorStyle style)
 {
     return(style._coroutineStateColor);
 }
 public override GUIStyle GetTextStyle(StateMachineEditorStyle style)
 {
     return(style._noteTextStyle);
 }
 public override Color GetColor(StateMachineEditorStyle style)
 {
     return(style._playableGraphStateColor);
 }
Пример #9
0
                public void Render(Rect renderedRect, Color borderColor, Color stateColor, StateMachineEditorStyle style, float borderSize)
                {
                    Color origBackgroundColor = GUI.backgroundColor;

                    GUI.backgroundColor = Color.clear;

                    GUIStyle stateLabelStyle = style._stateIdTextStyle;
                    GUIStyle labelStyle      = GetTextStyle(style);

                    GUI.BeginGroup(renderedRect, EditorUtils.ColoredRoundedBoxStyle);
                    {
                        Rect labelRect = new Rect(kMaxBorderSize, kMaxBorderSize, renderedRect.width - kShadowSize - (kMaxBorderSize * 2.0f), renderedRect.height - kShadowSize - (kMaxBorderSize * 2.0f));

                        float borderOffset = kMaxBorderSize - borderSize;

                        //Draw shadow
                        EditorUtils.DrawColoredRoundedBox(new Rect(labelRect.x + kShadowSize, labelRect.x + kShadowSize, labelRect.width, labelRect.height), kShadowColor);

                        //Draw white background
                        EditorUtils.DrawColoredRoundedBox(new Rect(borderOffset, borderOffset, renderedRect.width - kShadowSize - (borderOffset * 2.0f), renderedRect.height - kShadowSize - (borderOffset * 2.0f)), borderColor);

                        //Draw label with colored background
                        GUI.backgroundColor = stateColor;

                        GUIContent stateId = new GUIContent(GetEditableObject().GetStateIdLabel());

                        GUI.BeginGroup(labelRect, EditorUtils.ColoredRoundedBoxStyle);
                        {
                            float h, s, v;
                            Color.RGBToHSV(stateColor, out h, out s, out v);
                            Color textColor = v > 0.66f ? Color.black : Color.white;
                            stateLabelStyle.normal.textColor = textColor;
                            labelStyle.normal.textColor      = textColor;
                            labelStyle.active.textColor      = textColor;
                            labelStyle.focused.textColor     = textColor;
                            labelStyle.hover.textColor       = textColor;

                            GUI.Label(new Rect(0, 0, _rect.width, _rect.height), stateId, stateLabelStyle);

                            float seperatorY   = stateLabelStyle.CalcSize(stateId).y;
                            Color origGUIColor = GUI.color;
                            GUI.color = borderColor;
                            GUI.DrawTexture(new Rect(0, seperatorY, labelRect.width, 1), EditorUtils.OnePixelTexture);
                            GUI.color = origGUIColor;

                            Rect labelTextRect = new Rect(kLabelPadding * 0.5f, seperatorY + kStateSeperationSize, _rect.width - kLabelPadding, _rect.height);

                            GUI.Label(labelTextRect, GetStateDescription(), labelStyle);
                        }
                        GUI.EndGroup();
                    }
                    GUI.EndGroup();

                    GUI.backgroundColor = origBackgroundColor;
                }
Пример #10
0
 public virtual GUIStyle GetTextStyle(StateMachineEditorStyle style)
 {
     return(style._stateTextStyle);
 }
 public override Color GetColor(StateMachineEditorStyle style)
 {
     return(style._externalStateColor);
 }