Search Unity

Updating old UI, Need help with button On Click ()

Discussion in 'General Discussion' started by Proto-G, Oct 13, 2019.

Thread Status:
Not open for further replies.
  1. Proto-G

    Proto-G

    Joined:
    Nov 22, 2014
    Posts:
    213
  2. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,205
    For starters, the method that you want the button to call has to be public. Actual name isn't important.
    Code (csharp):
    1. public void OnMouseDown()
    2. {
    3.     Application.LoadLevel(SceneName);
    4. }
    After you've done that you simply need to click on the button, expand the "On Click ()" event, click the "+", drag the object containing the script over top of "None (Object)" and then in the dropdown to the right of it you need to navigate to the method and select it.

    upload_2019-10-13_13-14-5.png
     
    Mauri, Kiwasi, vakabaka and 1 other person like this.
  3. Proto-G

    Proto-G

    Joined:
    Nov 22, 2014
    Posts:
    213
    Brilliant! That worked. Now I can get all my buttons updated. Thank you so much @Ryiah Much appreciated!
     
  4. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,780
  5. Proto-G

    Proto-G

    Joined:
    Nov 22, 2014
    Posts:
    213
  6. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    9,052
    wrong forum. Closed.
     
Thread Status:
Not open for further replies.