void DrawNodeDescription(Rect thisNodeRect)
    {
        Color descriptionColor = (target as CommentNode).TextColor;

        NodeEditorPreferences.Settings prefs = NodeEditorPreferences.GetSettings();
        GUIStyle descriptionStyle            = XNodeUtils.ZoomBasedStyle(120f, 120f,
                                                                         NodeEditorWindow.current.zoom, prefs.minZoom, prefs.maxZoom, descriptionColor);

        Rect descriptionRect = thisNodeRect;

        descriptionRect.y     += 25f;
        descriptionRect.height = 140f;

        string descriptionText = !(target as CommentNode).Description.IsNullOrWhitespace()
                                ? (target as CommentNode).Description
                                : "<Empty>";

        (target as CommentNode).Description =
            EditorGUI.TextField(descriptionRect, descriptionText, descriptionStyle);

        Color descriptionRectColor = (target as CommentNode).Color;

        descriptionRectColor.a = .03f;

        EditorGUI.DrawRect(descriptionRect, descriptionRectColor);

        Color borderColor = (target as CommentNode).Color;

        borderColor.a = .3f;
        XNodeUtils.DrawBorderAroundRect(descriptionRect, 10f, borderColor);
        EditorGUIUtility.AddCursorRect(descriptionRect, MouseCursor.Text);
    }
    public override void OnBodyGUI()
    {
        EditorGUIUtility.labelWidth = 350;
        base.OnBodyGUI();

        //End the current GUI Area that is restricted to node's dimensions
        GUILayout.EndArea();

        //Show Label Above node
        Vector2 nodeLabelPos = NodeEditorWindow.current.GridToWindowPositionNoClipped(target.position +
                                                                                      new Vector2(0f, -60f));
        StateNode nodeAsState = target as StateNode;

        NodeEditorPreferences.Settings prefs = NodeEditorPreferences.GetSettings();
        GUIStyle labelStyle = XNodeUtils.ZoomBasedStyle(35f, 85f, NodeEditorWindow.current.zoom,
                                                        prefs.minZoom, prefs.maxZoom, new Color(.85f, .85f, 1f), FontStyle.Bold, TextAnchor.LowerCenter, false);

        GUI.Label(new Rect(nodeLabelPos, new Vector2(GetWidth(), 50f)), nodeAsState.GetName(),
                  labelStyle);

        //Put back the GUI area that is restricted to node's dimensions
        Vector2 nodePos = NodeEditorWindow.current.GridToWindowPositionNoClipped(target.position);

        GUILayout.BeginArea(new Rect(nodePos, new Vector2(GetWidth(), 4000)));
    }
Example #3
0
    public override void OnBodyGUI()
    {
        EditorGUIUtility.labelWidth = 120f;
        base.OnBodyGUI();

        //End the current GUI Area that is restricted to node's dimensions
        GUILayout.EndArea();

        Vector2 nodePos = NodeEditorWindow.current.GridToWindowPositionNoClipped(target.position);

        //Show Condition Preview below if collapsed
        if (collapsed)
        {
            Vector2 nodeLabelPos = NodeEditorWindow.current.GridToWindowPositionNoClipped(target.position +
                                                                                          new Vector2(17f, 130f));
            Vector2 topLeftPos = NodeEditorWindow.current.GridToWindowPositionNoClipped(target.position +
                                                                                        new Vector2(0f, 110));

            //Borders
            EditorGUI.DrawRect(new Rect(topLeftPos + new Vector2(5f, 0f), new Vector2(GetWidth() - 10, 300f)),
                               new Color(80f / 255f, 46f / 255f, 50f / 255f, 1f));

            //Text Area
            Rect textAreaRect = new Rect(topLeftPos + new Vector2(12f, 0f), new Vector2(GetWidth() - 25, 290f));
            EditorGUI.DrawRect(textAreaRect, new Color(0, 0, 0, .9f));

            //Condition Preview
            TransitionNode nodeAsTransition = target as TransitionNode;

            NodeEditorPreferences.Settings prefs = NodeEditorPreferences.GetSettings();
            GUIStyle labelStyle = XNodeUtils.ZoomBasedStyle(18f, 45f, NodeEditorWindow.current.zoom,
                                                            prefs.minZoom, prefs.maxZoom, new Color(1f, .85f, .85f), FontStyle.Normal);
            labelStyle.clipping = TextClipping.Clip;

            GUI.Label(textAreaRect, nodeAsTransition.ConditionPreview,
                      labelStyle);
        }


        //Put back the GUI area that is restricted to node's dimensions
        GUILayout.BeginArea(new Rect(nodePos, new Vector2(GetWidth(), 4000)));
    }