Пример #1
0
 /// <summary>
 /// Helper method for setting up custom colors using a skin.
 /// </summary>
 /// <param name="skin"></param>
 protected void SetSkin(GUISkin skin)
 {
     Skin = skin;
     //setup easy-access colors
     if (Skin == null)
     {
         Skin = GUISkin.CreateInstance <GUISkin>();
     }
     else
     {
         //we are using the state textcolor entries to define our editor's colors.
         //Background colors are normal states (Normal, Hover, Active, ...)
         //text colors are state events (onNormal, onHover, onActive, ...)
         EditorColors = Skin.GetStyle(EditorColorSource);
         if (EditorColors != null)
         {
             PrimaryColor   = EditorColors.normal.textColor;
             SecondaryColor = EditorColors.hover.textColor;
             TirchiaryColor = EditorColors.focused.textColor;
             TrimColor      = EditorColors.active.textColor;
             TextColor      = EditorColors.onNormal.textColor;
             TextColor2     = EditorColors.onFocused.textColor;
             TextHover      = EditorColors.onHover.textColor;
             TextActive     = EditorColors.onActive.textColor;
         }
         MenuItemStyle    = Skin.GetStyle("MenuItem");
         PopupWindowStyle = Skin.GetStyle("Popup Window");
     }
 }
Пример #2
0
    void OnGUI()
    {
        // fuel box background
        Texture2D bgTexture = new Texture2D(1, 1);

        bgTexture.SetPixel(0, 0, Color.red);
        bgTexture.Apply();
        GUISkin bgSkin = GUISkin.CreateInstance <GUISkin>();

        bgSkin.box.normal.background = bgTexture;
        GUI.skin = bgSkin;
        GUI.Box(new Rect(25, 20, 100, 10), GUIContent.none);

        // fuel left box
        Texture2D boxTexture = new Texture2D(1, 1);

        boxTexture.SetPixel(0, 0, Color.green);
        boxTexture.Apply();
        GUISkin boxSkin = GUISkin.CreateInstance <GUISkin>();

        boxSkin.box.normal.background = boxTexture;
        GUI.skin = boxSkin;
        GUI.Box(new Rect(25, 20, (biteScript.fuelLeft > 0 ? biteScript.fuelLeft : 0.1f), 10), GUIContent.none);
    }