Esempio n. 1
0
        public static GUIStyle Style(Color bgColor, int off = -1)
        {
            GUIStyle newStyle = new GUIStyle(GUI.skin.box);

            if (off < 0)
            {
                if (Screen.dpi != 120)
                {
                    newStyle.border = new RectOffset(off, off, off, off);
                }
                else if (FEditor_OneShotLog.CanDrawLog("dpi"))
                {
                    Debug.Log("<b>[HEY! UNITY DEVELOPER!]</b> It seems you have setted up incorrect DPI settings for unity editor. Check <b>Unity.exe -> Properties -> Compatibility -> Change DPI Settings -> Replace Scaling -> System / System (Upgraded)</b> And restart Unity Editor.");
                }
            }
            else
            {
                newStyle.border = new RectOffset(off, off, off, off);
            }

            Color[] solidColor = new Color[1] {
                bgColor
            };

            Texture2D bg = new Texture2D(1, 1);

            bg.SetPixels(solidColor); bg.Apply();
            newStyle.normal.background = bg;

            return(newStyle);
        }
Esempio n. 2
0
        public static GUIStyle Style(RectOffset padding, RectOffset margin, Color bgColor, Vector4 off, int zeroBorder = 0)
        {
            GUIStyle newStyle = new GUIStyle(GUI.skin.box);
            bool     g        = false;

            if (off.x < 0)
            {
                if (Screen.dpi == 120)
                {
                    if (FEditor_OneShotLog.CanDrawLog("dpi"))
                    {
                        Debug.Log("<b>[HEY! UNITY DEVELOPER!]</b> It seems you have setted up incorrect DPI settings for unity editor. Check <b>Unity.exe -> Properties -> Compatibility -> Change DPI Settings -> Replace Scaling -> System / System (Upgraded)</b> And restart Unity Editor.");
                    }
                }
                else
                {
                    g = true;
                }
            }
            else
            {
                g = true;
            }
            if (g)
            {
                newStyle.border = new RectOffset((int)off.x, (int)off.y, (int)off.z, (int)off.w);
            }
            newStyle.margin  = margin;
            newStyle.padding = padding;

            Texture2D bg;

            if (zeroBorder < 1)
            {
                bg = new Texture2D(1, 1);
                bg.SetPixels(new Color[1] {
                    bgColor
                }); bg.Apply();
            }
            else
            {
                int s = 16;
                bg            = new Texture2D(s, s);
                bg.filterMode = FilterMode.Point;
                Color[] c = new Color[s * s];
                for (int x = 0; x < s; x++)
                {
                    for (int y = 0; y < s; y++)
                    {
                        if (x < zeroBorder || x >= (s - zeroBorder) || y < zeroBorder || y >= (s - zeroBorder))
                        {
                            c[x + y * s] = Color.clear;
                        }
                        else
                        {
                            c[x + y * s] = bgColor;
                        }
                    }
                }

                bg.SetPixels(c); bg.Apply();
            }

            newStyle.normal.background = bg;

            return(newStyle);
        }