i have one script. but a dont now how to do that: if i colide with a game object with one tag, he shows a gui button for me what is wrong? can you fiz it to me?(i am a noob) i have other question. can i put images on my gui button? whats the script to i do that? my script: Code (JavaScript): #pragma strict var shop : boolean = false; function Start () { } function Update () { } function OnCollisionEnter(hit: Collision){ if(hit.gameObject.tag == "shop"){ shop = !shop; if (GUI.Button(Rect(100,150,50,25), "Skills")){} } }
You need to call legacy GUI functions from OnGUI(), not in the middle of OnCollisionEnter() but @BoredMormon is correct that you should absolutely look into the new UI.
The new UI is not primarily scripting like the old way, it's primarily graphical and it's far far better in every way. We can't create an example, for that reason. Check this out for more info: https://unity3d.com/learn/tutorials/modules/beginner/ui/ui-canvas