Beispiel #1
0
        public static GUIStyle CreateStyle(TextAnchor anchor, FontStyle fontStyle, int fontSize, bool wordWrap)
        {
            GUIStyle style = new GUIStyle();

            style.ApplyStyle(anchor, fontStyle, fontSize, wordWrap);
            return(style);
        }
Beispiel #2
0
 public static void ApplyStyle(this GUIStyle style, TextAnchor anchor, FontStyle fstyle, int fontSize, bool wordWrap, Color color)
 {
     if (style == null)
     {
         return;
     }
     style.ApplyStyle(anchor, fstyle, fontSize, wordWrap, new Color[6].Select(x => color).ToArray());
 }
Beispiel #3
0
 public static void ApplyStyle(this GUIStyle res, TextAnchor anchor, FontStyle style, int fontSize, bool wordWrap, Color[] colors)
 {
     if (res == null)
     {
         return;
     }
     res.ApplyStyle(anchor, style, fontSize, wordWrap);
     res.normal.textColor   = colors[0];
     res.hover.textColor    = colors[1];
     res.active.textColor   = colors[2];
     res.onNormal.textColor = colors[3];
     res.onHover.textColor  = colors[4];
     res.onActive.textColor = colors[5];
 }
Beispiel #4
0
 private static void InitializeStyles()
 {
     Textures.Initialize();
     Color[] textColorsArray = new Color[6] {
         TextColors[0].HexToColor(), TextColors[1].HexToColor(), TextColors[2].HexToColor(), TextColors[3].HexToColor(), TextColors[4].HexToColor(), TextColors[5].HexToColor()
     };
     //Box
     Box.ApplyStyle(TextAnchor.UpperCenter, FontStyle.Bold, FontSize + 2, true, textColorsArray[0]);
     Box.richText          = true;
     Box.normal.background = Textures.TextureCache[ElementType.Box][0];
     Box.hover.background  = Textures.TextureCache[ElementType.Box][0];
     Box.active.background = Textures.TextureCache[ElementType.Box][0];
     //Button
     Button.ApplyStyle(TextAnchor.MiddleCenter, FontStyle.Normal, FontSize, true, textColorsArray);
     Button.richText          = true;
     Button.normal.background = Textures.TextureCache[ElementType.Button][0];
     Button.hover.background  = Textures.TextureCache[ElementType.Button][1];
     Button.active.background = Textures.TextureCache[ElementType.Button][2];
     //Label
     Label.ApplyStyle(TextAnchor.MiddleLeft, FontStyle.Normal, FontSize, true, textColorsArray);
     Label.richText = true;
     LabelCenter.ApplyStyle(TextAnchor.MiddleCenter, FontStyle.Normal, FontSize, true, textColorsArray);
     LabelCenter.richText = true;
     //SelectionGrid
     SelectionGrid.ApplyStyle(TextAnchor.MiddleCenter, FontStyle.Normal, FontSize, false, textColorsArray);
     SelectionGrid.richText            = true;
     SelectionGrid.normal.background   = Textures.TextureCache[ElementType.SelectionGrid][0];
     SelectionGrid.hover.background    = Textures.TextureCache[ElementType.SelectionGrid][1];
     SelectionGrid.active.background   = Textures.TextureCache[ElementType.SelectionGrid][2];
     SelectionGrid.onNormal.background = Textures.TextureCache[ElementType.SelectionGrid][3];
     SelectionGrid.onHover.background  = Textures.TextureCache[ElementType.SelectionGrid][4];
     SelectionGrid.onActive.background = Textures.TextureCache[ElementType.SelectionGrid][5];
     //Slider
     Slider.normal.background   = Textures.TextureCache[ElementType.Slider][0];
     Slider.hover.background    = Textures.TextureCache[ElementType.Slider][1];
     Slider.active.background   = Textures.TextureCache[ElementType.Slider][2];
     Slider.onNormal.background = Textures.TextureCache[ElementType.Slider][3];
     Slider.onHover.background  = Textures.TextureCache[ElementType.Slider][4];
     Slider.onActive.background = Textures.TextureCache[ElementType.Slider][5];
     //SliderBody
     SliderBody.normal.background   = Textures.TextureCache[ElementType.SliderBody][0];
     SliderBody.hover.background    = Textures.TextureCache[ElementType.SliderBody][1];
     SliderBody.active.background   = Textures.TextureCache[ElementType.SliderBody][2];
     SliderBody.onNormal.background = Textures.TextureCache[ElementType.SliderBody][3];
     SliderBody.onHover.background  = Textures.TextureCache[ElementType.SliderBody][4];
     SliderBody.onActive.background = Textures.TextureCache[ElementType.SliderBody][5];
     SliderBody.fixedWidth          = Height;
     SliderBody.fixedHeight         = Height;
     //TextField
     TextField.ApplyStyle(TextAnchor.MiddleLeft, FontStyle.Normal, FontSize, false, textColorsArray);
     TextField.richText          = false;
     TextField.clipping          = TextClipping.Clip;
     TextField.normal.background = Textures.TextureCache[ElementType.TextField][0];
     TextField.hover.background  = Textures.TextureCache[ElementType.TextField][1];
     TextField.active.background = Textures.TextureCache[ElementType.TextField][2];
     //Toggle
     Toggle.normal.background   = Textures.TextureCache[ElementType.Toggle][0];
     Toggle.hover.background    = Textures.TextureCache[ElementType.Toggle][1];
     Toggle.active.background   = Textures.TextureCache[ElementType.Toggle][2];
     Toggle.onNormal.background = Textures.TextureCache[ElementType.Toggle][3];
     Toggle.onHover.background  = Textures.TextureCache[ElementType.Toggle][4];
     Toggle.onActive.background = Textures.TextureCache[ElementType.Toggle][5];
     //ToggleButton
     TextButton.ApplyStyle(TextAnchor.MiddleRight, FontStyle.Normal, FontSize, true, new Color[6] {
         white, orange, yellow, white, white, white
     });
     TextButton.richText          = true;
     TextButton.normal.background = GUIBase.EmptyTexture;
     TextButton.normal            = TextButton.hover = TextButton.active;
     SetFont(Font);
 }