Gui not showing.

Hey Alright i figured out i could not use the Canvas. so i have coded the stuff for a script so like i have a barracks and coded a script for that… that will use the buttons etc… the problem is that the script compiles but the buttons do not show up…
HUD_Barracks.cs

using UnityEngine;
using System.Collections;

public class HUD_Barracks : MonoBehaviour
{
    //Spawn Location
    public Transform spawn;
    public Transform goToAfterSpawn;
    //public Player
    private PlayerScript Usercube;

    //public Resources
    private Resources UserResources;
    //Icons
    public Texture2D icon1, icon2, icon3, icon4, icon5, icon6, icon7, icon8, icon9, icon10, icon11, icon12, icon13, icon14, icon15, icon16, icon17, icon18;
    //drag Selection
    public bool selected = false;
    //private Vector3 moveToDest = Vector3.zero;
    public float floorOffSet = 1;
    //Click Select
    private bool selectionByClick = false;


    // Use this for initialization
    void Start ()
    {    //using scripts attached to User
        GameObject user = GameObject.Find("UserCube");
        //usings Stuff from PlayerScript Script
        PlayerScript Usercube = user.GetComponent<PlayerScript>();
        //usings Stuff from Resources Script
        Resources UserResources = user.GetComponent<Resources>();
    }

    void OnGUI()
    {
        if(Usercube && Usercube.human) //checks to see if user is human
        {
            DrawButtons();
        }
    }

    // Update is called once per frame
    private void Update ()
    {      

        //Place Layer Unit Control Here.
        if (Input.GetMouseButton(0))
        {

            if (!selectionByClick)
            {
                Vector3 camPos = Camera.main.WorldToScreenPoint (transform.position);
                camPos.y = CamOP.InvertMouseY(camPos.y);
                selected = CamOP.selection.Contains (camPos);
            }
            if (selected)
            {
                gameObject.GetComponentInChildren<Projector>().enabled = true;

            }
            else
            {
                gameObject.GetComponentInChildren<Projector>().enabled = false;
            }
              
        }
    }
    //buttons for barracks
    private void DrawButtons()
    {
        // Make a group
        GUI.BeginGroup (new Rect (Screen.width - 310,Screen.height - 270,300,260));
        // All rectangles are now adjusted to the group. (0,0) is the topleft corner of the group.
      
        //(0__PositionWidth,0__PositionHeight,0__BOXWidth,0__BOXHeight)
        //Row1---------------------------------------------------------------------------------------------------------------------------------
        //Button1
        GUI.RepeatButton (new Rect (0,80,60,60), new GUIContent ("", icon1, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
        //Button2
        GUI.RepeatButton (new Rect (60,80,60,60), new GUIContent ("", icon2, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
        //Button3
        GUI.RepeatButton (new Rect (120,80,60,60), new GUIContent ("", icon3, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
        //Button4
        GUI.RepeatButton (new Rect (180,80,60,60), new GUIContent ("", icon4, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
        //Button5
        GUI.RepeatButton (new Rect (240,80,60,60), new GUIContent ("", icon5, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
        //Button6
        GUI.RepeatButton (new Rect (300,80,60,60), new GUIContent ("", icon6, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
        //Row2---------------------------------------------------------------------------------------------------------------------------------
        //Button7
        GUI.RepeatButton (new Rect (0,140,60,60), new GUIContent ("", icon7, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
        //Button8
        GUI.RepeatButton (new Rect (60,140,60,60), new GUIContent ("", icon8, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
        //Button9
        GUI.RepeatButton (new Rect (120,140,60,60), new GUIContent ("", icon9, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
        //Button10
        GUI.RepeatButton (new Rect (180,140,60,60), new GUIContent ("", icon10, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
        //Button11
        GUI.RepeatButton (new Rect (240,140,60,60), new GUIContent ("", icon11, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
        //Button12
        GUI.RepeatButton (new Rect (300,140,60,60), new GUIContent ("", icon12, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
        //Row3---------------------------------------------------------------------------------------------------------------------------------
        //Button13
        GUI.RepeatButton (new Rect (0,200,60,60), new GUIContent ("", icon13, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
        //Button14
        GUI.RepeatButton (new Rect (60,200,60,60), new GUIContent ("", icon14, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
        //Button15
        GUI.RepeatButton (new Rect (120,200,60,60), new GUIContent ("", icon15, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
        //Button16
        GUI.RepeatButton (new Rect (180,200,60,60), new GUIContent ("", icon16, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
        //Button17
        GUI.RepeatButton (new Rect (240,200,60,60), new GUIContent ("", icon17, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
        //Button18
        GUI.RepeatButton (new Rect (300,200,60,60), new GUIContent ("", icon18, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
      
        // End the group we started above.
        GUI.EndGroup ();
    }


    //Function for SimpleMouseClick
    private void OnMouseDown()
    {
        selectionByClick = true;
        selected = true;
    }
    private void OnMouseUp()
    {
        if (selectionByClick)
            selected = true;
      
        selectionByClick = false;
    }  

}

now HUD CS is where i got it working and it works fine…

using UnityEngine;
using System.Collections;

public class HUD : MonoBehaviour {


    //public Player
    private PlayerScript User;
    //Icons
    public Texture2D icon1, icon2, icon3, icon4, icon5, icon6, icon7, icon8, icon9, icon10, icon11, icon12, icon13, icon14, icon15, icon16, icon17, icon18;



    // Use this for initialization
    void Start ()
    {
        User = transform.root.GetComponent< PlayerScript >();
    }
  
    // Update is called once per frame
    void OnGUI()
    {
        if(User && User.human) //checks to see if user is human
        {
            DrawMiniMap();
            DrawResourceBar();
            DrawButtons();
        }
    }
    //Creates the OrderBar for HUD
    private void DrawMiniMap()
    {
        GUI.Box (new Rect (10,Screen.height - 110,100,100), "MiniMap");
    }
    //creates the ResourceBar for HUD
    private void DrawResourceBar()
    {
        //resources go here
    }
    private void DrawButtons()
    {

        // Make a group on the center of the screen
        GUI.BeginGroup (new Rect (Screen.width - 310,Screen.height - 270,300,260));
        // All rectangles are now adjusted to the group. (0,0) is the topleft corner of the group.

        //(0__PositionWidth,0__PositionHeight,0__BOXWidth,0__BOXHeight)
        //Row1---------------------------------------------------------------------------------------------------------------------------------
        //Button1
        GUI.RepeatButton (new Rect (0,80,60,60), new GUIContent ("", icon1, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
        //Button2
        GUI.RepeatButton (new Rect (60,80,60,60), new GUIContent ("", icon2, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
        //Button3
        GUI.RepeatButton (new Rect (120,80,60,60), new GUIContent ("", icon3, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
        //Button4
        GUI.RepeatButton (new Rect (180,80,60,60), new GUIContent ("", icon4, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
        //Button5
        GUI.RepeatButton (new Rect (240,80,60,60), new GUIContent ("", icon5, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
        //Button6
        GUI.RepeatButton (new Rect (300,80,60,60), new GUIContent ("", icon6, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
        //Row2---------------------------------------------------------------------------------------------------------------------------------
        //Button7
        GUI.RepeatButton (new Rect (0,140,60,60), new GUIContent ("", icon7, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
        //Button8
        GUI.RepeatButton (new Rect (60,140,60,60), new GUIContent ("", icon8, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
        //Button9
        GUI.RepeatButton (new Rect (120,140,60,60), new GUIContent ("", icon9, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
        //Button10
        GUI.RepeatButton (new Rect (180,140,60,60), new GUIContent ("", icon10, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
        //Button11
        GUI.RepeatButton (new Rect (240,140,60,60), new GUIContent ("", icon11, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
        //Button12
        GUI.RepeatButton (new Rect (300,140,60,60), new GUIContent ("", icon12, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
        //Row3---------------------------------------------------------------------------------------------------------------------------------
        //Button13
        GUI.RepeatButton (new Rect (0,200,60,60), new GUIContent ("", icon13, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
        //Button14
        GUI.RepeatButton (new Rect (60,200,60,60), new GUIContent ("", icon14, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
        //Button15
        GUI.RepeatButton (new Rect (120,200,60,60), new GUIContent ("", icon15, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
        //Button16
        GUI.RepeatButton (new Rect (180,200,60,60), new GUIContent ("", icon16, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
        //Button17
        GUI.RepeatButton (new Rect (240,200,60,60), new GUIContent ("", icon17, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
        //Button18
        GUI.RepeatButton (new Rect (300,200,60,60), new GUIContent ("", icon18, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
      
        // End the group we started above. This is very important to remember!
        GUI.EndGroup ();


    }
}

but the minute i try place it in the barracks script nothing…

Do you need to add using UnityEngine.UI or is that for the canvas? Sorry, I’m not up with ui, I’m just starting to use it.

Hey bro no i dont need to because im not using the canvas…

here is the code to fix it… i found out that looking for if it was human seems to be not working… :confused:

using UnityEngine;
using System.Collections;

public class HUD_Barracks : MonoBehaviour
{
    //Spawn Location
    public Transform spawn;
    public Transform goToAfterSpawn;
    //public Player
    //private PlayerScript Usercube;

    //public Resources
    //private Resources UserResources;
    //Icons
    public Texture2D icon1, icon2, icon3, icon4, icon5, icon6, icon7, icon8, icon9, icon10, icon11, icon12, icon13, icon14, icon15, icon16, icon17, icon18;
    //drag Selection
    public bool selected = false;
    //private Vector3 moveToDest = Vector3.zero;
    public float floorOffSet = 1;
    //Click Select
    private bool selectionByClick = false;


    // Use this for initialization
    void Start ()
    {    //using scripts attached to User
        GameObject user = GameObject.Find("UserCube");
        //usings Stuff from PlayerScript Script
        PlayerScript Usercube = user.GetComponent<PlayerScript>();
        //usings Stuff from Resources Script
        Resources UserResources = user.GetComponent<Resources>();
    }

    void OnGUI()
    {
        if (!selected)
        {

        }

        else
        {
            DrawButtons ();
        }
    }

    // Update is called once per frame
    void Update ()
    {       

        //Place Layer Unit Control Here.
        if (Input.GetMouseButton(0))
        {

            if (!selectionByClick)
            {
                Vector3 camPos = Camera.main.WorldToScreenPoint (transform.position);
                camPos.y = CamOP.InvertMouseY(camPos.y);
                selected = CamOP.selection.Contains (camPos);
            }
            if (selected)
            {
                gameObject.GetComponentInChildren<Projector>().enabled = true;

            }
            else
            {
                gameObject.GetComponentInChildren<Projector>().enabled = false;

            }
               
        }
    }
    //buttons for barracks
    private void DrawButtons()
    {
        // Make a group on the center of the screen
        GUI.BeginGroup (new Rect (Screen.width - 310,Screen.height - 270,300,260));
        // All rectangles are now adjusted to the group. (0,0) is the topleft corner of the group.
       
        //(0__PositionWidth,0__PositionHeight,0__BOXWidth,0__BOXHeight)
        //Row1---------------------------------------------------------------------------------------------------------------------------------
        //Button1
        GUI.RepeatButton (new Rect (0,80,60,60), new GUIContent ("", icon1, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
        //Button2
        GUI.RepeatButton (new Rect (60,80,60,60), new GUIContent ("", icon2, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
        //Button3
        GUI.RepeatButton (new Rect (120,80,60,60), new GUIContent ("", icon3, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
        //Button4
        GUI.RepeatButton (new Rect (180,80,60,60), new GUIContent ("", icon4, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
        //Button5
        GUI.RepeatButton (new Rect (240,80,60,60), new GUIContent ("", icon5, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
        //Button6
        GUI.RepeatButton (new Rect (300,80,60,60), new GUIContent ("", icon6, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
        //Row2---------------------------------------------------------------------------------------------------------------------------------
        //Button7
        GUI.RepeatButton (new Rect (0,140,60,60), new GUIContent ("", icon7, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
        //Button8
        GUI.RepeatButton (new Rect (60,140,60,60), new GUIContent ("", icon8, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
        //Button9
        GUI.RepeatButton (new Rect (120,140,60,60), new GUIContent ("", icon9, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
        //Button10
        GUI.RepeatButton (new Rect (180,140,60,60), new GUIContent ("", icon10, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
        //Button11
        GUI.RepeatButton (new Rect (240,140,60,60), new GUIContent ("", icon11, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
        //Button12
        GUI.RepeatButton (new Rect (300,140,60,60), new GUIContent ("", icon12, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
        //Row3---------------------------------------------------------------------------------------------------------------------------------
        //Button13
        GUI.RepeatButton (new Rect (0,200,60,60), new GUIContent ("", icon13, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
        //Button14
        GUI.RepeatButton (new Rect (60,200,60,60), new GUIContent ("", icon14, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
        //Button15
        GUI.RepeatButton (new Rect (120,200,60,60), new GUIContent ("", icon15, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
        //Button16
        GUI.RepeatButton (new Rect (180,200,60,60), new GUIContent ("", icon16, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
        //Button17
        GUI.RepeatButton (new Rect (240,200,60,60), new GUIContent ("", icon17, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
        //Button18
        GUI.RepeatButton (new Rect (300,200,60,60), new GUIContent ("", icon18, "This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf This is the tooltip1 asdfasdf asdf asdf asd fas df asdf asdf asdf"));
        GUI.Label (new Rect (0,0,290,80), GUI.tooltip);
       
        // End the group we started above. This is very important to remember!
        GUI.EndGroup ();
    }


    //Function for SimpleMouseClick
    private void OnMouseDown()
    {
        selectionByClick = true;
        selected = true;
    }
    private void OnMouseUp()
    {
        if (selectionByClick)
            selected = true;
       
        selectionByClick = false;
    }   

}

Now the Only issue is that once i try click a button the menu goes away :confused: i think its detecting that the barracks is deselected. trying to sort it out… but lol im not a coder… so figuring as i try things…

mostly out of curiosity, but why have you made that assertion? a quick skim of the code doesn’t seem to show anything that the newer canvas approach couldn’t support.

(ignoring the “too far down the path to change forks now” :P)

You have to analyze what’s happening there.
I assume you mean the buttons when you’re talking about the menu.

They will only be drawn when ‘selected’ is true. Now check your code, where could ‘false’ be assigned to that variable?
Maybe here:

if (!selectionByClick)
{
    Vector3 camPos = Camera.main.WorldToScreenPoint(transform.position);
    camPos.y = CamOP.InvertMouseY(camPos.y);
    selected = CamOP.selection.Contains (camPos);
}

Add a Debug.Log(selected); after those three lines. What does it print?

Also, it will be a pain to maintain the code, with all the positions etc.
Try to look into loops and arrays. Work with offset-variables.

HAHA na bud i posted a while back here asking for help an had 300 people read it and just not reply… eventually i just did what i could and came up with this…
once it is working i can just apply each script to each building even if it is a long way around… i am not a coder… i am an artist. lol.

well bud to me you are honestly speaking about stuff i am not aware of or do not know how to use… i can basically read and understand some of peoples code/ explanations…

but ill see if i can maybe read that link you sent me… and find something…

I fixed the link which was somehow placed in the code, i assume that happened because i copied the code snippet from the post without qouting it.
Anyway, all i recommended in regards to the problem was adding one line to your current code, this one: Debug.Log(selected);
The other suggestions about arrays etc. are just for you to look up, they have nothing to do with the actual problem but might help to reduce your method to about 4-5 lines and you could maintain the code much easier then.

i guess i could try using (GuiContent.GuiContent) but not sure how i am going to put it to use there is nothing really helping with showing me how it is used.

this is the debug error i got bro

See, now you’re a bit closer to the cause of the problem.
The method returns false and will be executed when you click your mousebutton due to the if statement i quoted above. Thus, your menu will disappear (it’s only drawn when selected is true).

And now you have to dig further, what’s CamOP.selection? Probably a collection of any kind (List, ArrayList, Set,…) containing Vector3 values.
The method Contains() searches through that collection and tries to find a match (match means, one object has to be equal to the other, the definition of equality depends on the type as you can override it). If it finds one, it will return true, otherwise false. Latter one happens, because the vectors are probably compared component by component, each component being a float. And float value comparisons are not good at all if not properly done. Don’t rely on that.

Sorry was at gym… umm here is my CAMOP script so you can better understand…

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class CamOP : MonoBehaviour
{
    //Reference to player
    private PlayerScript User;

    //Drag Select
    public Texture2D SelectionHightLight = null;
    public static Rect selection = new Rect(0, 0, 0, 0);
    private Vector3 StartClick = -Vector3.one;
   

    //Move To
    private static Vector3 moveToDestination = Vector3.zero;
    private static List<string> passables = new List<string>() { "Terrain" }; //Make Sure To Name the Terrain Floor

    //On Start Find Player
    void Start()
    {
        User = transform.root.GetComponent< PlayerScript >();
    }
    // Update is called once per frame
    void Update ()
    {
        if(User.human) //checks to see if user is HUMAN
        {
            CheckCamera ();   
            Cleanup ();
        }
    }

    //Setting up the drag box selection
    private void CheckCamera()
    {
        if (Input.GetMouseButtonDown (0))
            StartClick = Input.mousePosition;
        else if (Input.GetMouseButtonUp(0))
            StartClick = -Vector3.one;

        if (Input.GetMouseButton (0))
        {
            selection = new Rect (StartClick.x, InvertMouseY (StartClick.y), Input.mousePosition.x - StartClick.x, InvertMouseY (Input.mousePosition.y) - InvertMouseY (StartClick.y));

            if (selection.width < 0)
            {
                selection.x += selection.width;
                selection.width = -selection.width;
            }
            if (selection.height < 0)
            {
                selection.y += selection.height;
                selection.height = -selection.height;
            }
        }

    }

    //Drag Box Creation
    private void OnGUI()
    {
        if (StartClick != -Vector3.one)
        {
            GUI.color = new Color(1, 1, 1, 0.5f);
            GUI.DrawTexture(selection, SelectionHightLight);
        }
    }

    public static float InvertMouseY(float y)
    {
        return Screen.height - y;
    }

    private void Cleanup()
    {
        if (!Input.GetMouseButtonUp (1))
            moveToDestination = Vector3.zero;
    }

    public static Vector3 GetDestination()
    {
        if (moveToDestination == Vector3.zero)
        {
            RaycastHit hit;
            Ray r = Camera.main.ScreenPointToRay(Input.mousePosition);

            if (Physics.Raycast (r, out hit))
            {
                while (!passables.Contains (hit.transform.gameObject.name))
                {
                    if (!Physics.Raycast(hit.point + r.direction * 0.1f, r.direction, out hit))
                        break;
                }
            }

            if (hit.transform != null)
                moveToDestination = hit.point;
        }

        return moveToDestination;
    }
}

Like i said but i usually follow tutorials as i understand probably the bare minimum… then i try and recreate what they do without copying anything down and if i get stuck I check myself… this out of all the tutorials was the best one i found with regards to selecting a unit and telling it to move…

Okay that was a wrong guess with the collection, it’s a Rectangle. :stuck_out_tongue:
So you want to do some kind of unit selection i guess.

In order to find out what’s going wrong, you should add some more Debug.Logs to your script or even better, as you have to compare values now, make OnGUI draw some labels and make them display the following values:

  • CamOP.selection: position/coordinates and its size
  • camPos (which is the transforms position in screen space)

Then, have a look at the values that will be shown.

Have you checked out PlayMaker? A bit expensive but artists I know like it as it makes scripting visual (you still need a basic understanding though) & all the links/nodes let you see where the code is up to while it is running.

Sorry, I can’t actually help with the issue but thought I’d mention it in case you hadn’t heard of it.

sorry bud i am little confused… what you mean? what do i have to compare?

hmm ill create a label and place the vales in there… but what is it that you are looking for?

Yea bud i have heard its like unreals VS but the issue is that you have to learn a whole new thing and keeps you from making it the way you want…

lol the issues are real… :confused:

if its referencing another script…? wouldnt i use the other ones i have defined?

You have to put CamOP.selection in there, that should already print the coordinates and the size.
Sorry if that confuses you alot, but you’re supposed to compare the values written to the labels:

  • the rect of the selection window that you are creating with your mouse
  • the screen space position of your transform

Why? Because you calculate the screen space position of the transform that holds the HUD_Barracks script, for example 500,400. And you calculate a rectangle that you create for box-selection which has to contain this position. Otherwise you’ll get false from the Contains() that method i mentioned in previous posts.

There will be problems with this script i guess, but that’s not the point at the moment. And it makes it really hard to find the point of failure because everything seems to tightly coupled and dependant on each other.

umm would it be better for me to send you the project? so you can test it out yourself? or do you just need me to place what you required in?

Any thing i try it fails to compile…

i have tried

GUI.Label (new Rect (0,0,290,80), CamOP.selection);

GUI.Label (new Rect (0,0,290,80), selection);

GUI.Label (new Rect (0,0,290,80), selected);

GUI.Label (new Rect (0,0,290,80), CamOP.selection.contains);

is there maybe a way to make it stop returning false when it has anything with GUI in it?

You could send me the project, however, it will be the best if you take part in finding the solution.

Add .ToString() to CamOP.selection so that it reads CamOP.selection.ToString(), sorry for all the small things that I leave out. The Label requires GuiContent or a string, that’s why you have to call ToString() in this case or concatenate it with another (empty) string. ToString() is better though.