Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Buttons to elevator

Discussion in 'Scripting' started by Megulan, Jul 15, 2023.

  1. Megulan

    Megulan

    Joined:
    Aug 17, 2021
    Posts:
    12
    So I added elevator to my game but now I want to control it with buttons, so I made public void in my elevator script and now I have no idea how to make game object a button.. I would want to make if I click on it it will activate the public void in my other script but I dont know how to make it anything I dont even know how to make a button without UI, couldnt find any help in youtube so I came here.




    I got it! but idk how to delete this post XD
     
    Last edited: Jul 16, 2023
  2. MaskedMouse

    MaskedMouse

    Joined:
    Jul 8, 2014
    Posts:
    1,057
    You can put a physics raycaster on the camera.
    Add a collider to the elevator button.
    Add a component on the elevator button with the
    IPointerClickHandler
    interface implemented.
    For testing purposes just put a
    Debug.Log("Clicked", this);
    in and test if it works
     
  3. Megulan

    Megulan

    Joined:
    Aug 17, 2021
    Posts:
    12
    ty