Exemplo n.º 1
0
    public override void OnGUI(Rect position)
    {
#if UNITY_EDITOR
        ShowInfoAttribute attributes = (ShowInfoAttribute)attribute;

        // DRAW BOX
        Rect box = new Rect(position.x + ShowInfoWindow.defaultWidth,
                            position.y + ShowInfoWindow.defaultSpaceBefore,
                            position.width - (ShowInfoWindow.defaultWidth * 2), 20 + ShowInfoWindow.defaultHeight);

        Color bg = ShowInfoStyles.ConfigColor(ShowInfoWindow.defaultBoxColor);
        if (ShowInfoWindow.boxEnabled)
        {
            EditorGUI.DrawRect(box, bg);
        }

        // DRAW TEXT
        box = new Rect(box.x + ShowInfoWindow.defaultInnerWidth, box.y,
                       box.width - (ShowInfoWindow.defaultInnerWidth * 2), box.height);


        Color    c     = ShowInfoStyles.ConfigColor(ShowInfoWindow.defaultColor);
        GUIStyle style = new GUIStyle(EditorStyles.label);
        style.fontStyle        = ShowInfoWindow.defaultStyle;
        style.alignment        = ShowInfoWindow.defaultAnchor;
        style.fontSize         = ShowInfoWindow.defaultSize;
        style.normal.textColor = new Color(c.r, c.g, c.b);

        GUI.Label(box, attributes.writing, style);
#endif
    }
Exemplo n.º 2
0
    //

    void OnGUI()
    {
        GUILayout.Label("Set the configuration for your custom Text Hint.");


        EditorGUILayout.Space();

        if (defaultSize < 10)
        {
            defaultSize = 10;
        }
        if (defaultSize > 100)
        {
            defaultSize = 100;
        }

        defaultSpaceBefore = EditorGUILayout.IntField("Space Before", defaultSpaceBefore);
        if (defaultSpaceBefore < -2)
        {
            defaultSpaceBefore = -2;
        }
        if (defaultSpaceBefore > 100)
        {
            defaultSpaceBefore = 100;
        }

        defaultHeight = EditorGUILayout.IntField("Height", defaultHeight);
        if (defaultHeight < -10)
        {
            defaultHeight = -10;
        }
        if (defaultHeight > 100)
        {
            defaultHeight = 100;
        }

        defaultSpaceAfter = EditorGUILayout.IntField("Space After", defaultSpaceAfter);
        if (defaultSpaceAfter < 0)
        {
            defaultSpaceAfter = 0;
        }
        if (defaultSpaceAfter > 100)
        {
            defaultSpaceAfter = 100;
        }

        EditorGUILayout.Space();

        defaultWidth = EditorGUILayout.IntField("Width", defaultWidth);
        if (defaultWidth < 0)
        {
            defaultWidth = 0;
        }
        if (defaultWidth > 100)
        {
            defaultWidth = 100;
        }

        defaultInnerWidth = EditorGUILayout.IntField("Inner Width", defaultInnerWidth);
        if (defaultInnerWidth < -50)
        {
            defaultInnerWidth = -50;
        }
        if (defaultInnerWidth > 100)
        {
            defaultInnerWidth = 100;
        }

        EditorGUILayout.Space();

        defaultAnchor = (TextAnchor)EditorGUILayout.EnumPopup("Anchor", defaultAnchor);
        defaultStyle  = (FontStyle)EditorGUILayout.EnumPopup("Style", defaultStyle);

        EditorGUILayout.Space();

        defaultSize = EditorGUILayout.IntField("Text Size", defaultSize);
        boxEnabled  = EditorGUILayout.Toggle("Show Box", boxEnabled);

        EditorGUILayout.Space();

        defaultColor    = (ShowInfoColor)EditorGUILayout.EnumPopup("Text Color", defaultColor);
        defaultBoxColor = (ShowInfoColor)EditorGUILayout.EnumPopup("Box Color", defaultBoxColor);

        EditorGUILayout.Space();

        sample = EditorGUILayout.TextField("Hint", sample);

        ///

        Rect lr = GUILayoutUtility.GetLastRect();

        int bugFix = 20;

        if (boxEnabled)
        {
            EditorGUI.DrawRect(new Rect(lr.position.x + defaultWidth,
                                        lr.position.y + bugFix + defaultSpaceBefore, lr.width - defaultWidth * 2,
                                        lr.height + defaultHeight + 2), ShowInfoStyles.ConfigColor(defaultBoxColor));
        }

        GUIStyle style = new GUIStyle(EditorStyles.label);

        style.fontStyle        = defaultStyle;
        style.alignment        = defaultAnchor;
        style.fontSize         = Mathf.RoundToInt(defaultSize);
        style.normal.textColor = ShowInfoStyles.ConfigColor(defaultColor);

        GUI.Label(new Rect(lr.position.x + defaultWidth + defaultInnerWidth,
                           lr.position.y + bugFix + defaultSpaceBefore, lr.width - defaultWidth - defaultInnerWidth,
                           lr.height + defaultHeight + 2), sample, style);

        EditorGUILayout.Space(defaultSpaceBefore + defaultHeight + defaultSpaceAfter + bugFix - 4);

        ///

        if (GUILayout.Button("Apply"))
        {
            Save();
        }

        EditorGUILayout.Space();

        if (GUILayout.Button("Clear Data"))
        {
            EditorPrefs.DeleteAll();
        }
    }