Search Unity

My GUI HUD isn't showing up?!?

Discussion in 'Scripting' started by PandaMan2299, Jul 24, 2014.

  1. PandaMan2299

    PandaMan2299

    Joined:
    Jul 8, 2014
    Posts:
    10
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections.Generic;
    3.  
    4. public class HUD : MonoBehaviour {
    5.     public GUISkin resourceSkin, ordersSkin;
    6.     private const int ORDERS_BAR_WIDTH = 150, RESOURCE_BAR_HEIGHT = 40;
    7.     private Player player;
    8.  
    9.  
    10.     void Start () {
    11.         player = transform.root.GetComponent<Player>();
    12.     }
    13.  
    14.    
    15.     void OnGUI () {
    16.         if(player.human) {
    17.             DrawOrdersBar();
    18.             DrawResourceBar();
    19.         }
    20.     }
    21.     private void DrawOrdersBar() {
    22.         GUI.skin = ordersSkin;
    23.         GUI.BeginGroup(new Rect(Screen.width-ORDERS_BAR_WIDTH,RESOURCE_BAR_HEIGHT,ORDERS_BAR_WIDTH,Screen.height-RESOURCE_BAR_HEIGHT));
    24.         GUI.Box(new Rect(0,0,ORDERS_BAR_WIDTH,Screen.height-RESOURCE_BAR_HEIGHT),"");
    25.         GUI.EndGroup();
    26.     }
    27.     private void DrawResourceBar() {
    28.         GUI.skin = resourceSkin;
    29.         GUI.BeginGroup(new Rect(0,0,Screen.width,RESOURCE_BAR_HEIGHT));
    30.         GUI.Box(new Rect(0,0,Screen.width,RESOURCE_BAR_HEIGHT),"");
    31.         GUI.EndGroup();
    32.         }
    33. }


    PLEASE HELP!
     
  2. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    1) Is the script attached to an object?

    2) have you confirmed that Player.human is true?

    3) Any error messages?
     
    LeftyRighty likes this.
  3. PandaMan2299

    PandaMan2299

    Joined:
    Jul 8, 2014
    Posts:
    10
    i have fixed it

    i had put the textures in the wrong gui slot