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’re making changes to the Unity Runtime Fee pricing policy that we announced on September 12th. Access our latest thread for more information!
    Dismiss Notice
  3. Dismiss Notice

[SOLVED]OnClick() appears to not get executed when clicking on my button

Discussion in 'UGUI & TextMesh Pro' started by agentc0re, Jan 30, 2015.

  1. agentc0re

    agentc0re

    Joined:
    Feb 28, 2014
    Posts:
    77
    Here is a screen shot of my canvas and button setup. http://gyazo.com/8ca2dca8eef188c096010f9f8c9df642

    The InGameGUI.OnRetryLevel() code is:

    public void OnRetryLevel()
    {
    GUImode = "gaming";
    Time.timeScale = 1.0f;
    Application.LoadLevel(Application.loadedLevel);
    }

    Heres the weird thing. The Prefab of my InGameGUIPanel is used in my Level_1 scene. It's setup the exact same way and it works properly. I did add a Debug.Log in the above code to see if it was getting clicked but not executing properly or something, but i didn't get any console output. This is why i think the OnClick() function isn't working like it should.

    I have several of these On Click() events setup too. None of which seem to be working in my Level_2 scene, but do work in my Level_1 scene. I'm fairly stumped as to why.

    Im on the latest Unity 4.6.2

    Thank you,
    -Jon
     
    Last edited: Jan 30, 2015
  2. Ramsdal

    Ramsdal

    Joined:
    Oct 18, 2013
    Posts:
    251
    Just to be sure? Is the EventSystem component that gets created when adding the initial canvas to a scene present in level2? You say you prefab the UI, perhaps you missed that one?
     
  3. agentc0re

    agentc0re

    Joined:
    Feb 28, 2014
    Posts:
    77
    Adding the Eventsystem is what fixed it. Thank you so much!
     
    Ramsdal likes this.