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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

UI clicking error

Discussion in 'UGUI & TextMesh Pro' started by Von_Dutch, Mar 16, 2015.

  1. Von_Dutch

    Von_Dutch

    Joined:
    May 7, 2014
    Posts:
    10
    So when I create a UI button I'm unable to test it when I hit the play button. Any suggestions on what to do? I've put the canvas on the top of all the objects but that didn't fix it. Though it does work when I build and play it. Thanks in advance
     
  2. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,685
    Hmm, have you updated to the latest release? (4.6.3/5.0.0f4)

    You should have no issues using the UI in the editor pressing play, especially if it is working on a platform
     
    Von_Dutch likes this.
  3. SeasiaInfotechind

    SeasiaInfotechind

    Joined:
    Nov 17, 2014
    Posts:
    32
    You should call it in a script.
    For example if you want to print "hello" on button click write following code in c# script-

    public void OnClickButton()
    {
    print("hello");
    }

    after this,attach this to any game object and drag that gameobject in to OnClick() function defined in button inspector and select OnClickButton() function from drop down.
     
  4. Von_Dutch

    Von_Dutch

    Joined:
    May 7, 2014
    Posts:
    10
    It was so basic lol I had 4. Thanks for the help