Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

images and colisions

Discussion in 'Scripting' started by 787gabriel777, Jul 28, 2015.

  1. 787gabriel777

    787gabriel777

    Joined:
    Jul 20, 2015
    Posts:
    65
    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):
    1. #pragma strict
    2. var shop : boolean = false;
    3.  
    4. function Start () {
    5.  
    6. }
    7.  
    8. function Update () {
    9.  
    10. }  
    11.           function OnCollisionEnter(hit: Collision){
    12.          if(hit.gameObject.tag == "shop"){
    13.          shop = !shop;
    14.          if (GUI.Button(Rect(100,150,50,25), "Skills")){}
    15.          }
    16.        
    17.        
    18.        
    19.          }
     
  2. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Check out the new UI. GUI.Button is obsolete.
     
  3. GroZZleR

    GroZZleR

    Joined:
    Feb 1, 2015
    Posts:
    3,201
    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.
     
    Last edited: Jul 28, 2015
    Kiwasi likes this.
  4. 787gabriel777

    787gabriel777

    Joined:
    Jul 20, 2015
    Posts:
    65
    can you create one example for me?
     
  5. DonLoquacious

    DonLoquacious

    Joined:
    Feb 24, 2013
    Posts:
    1,667
  6. 787gabriel777

    787gabriel777

    Joined:
    Jul 20, 2015
    Posts:
    65
    ok thanks.