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

Problem with a Button

Discussion in '2D' started by LHarris134, Dec 15, 2015.

  1. LHarris134

    LHarris134

    Joined:
    Feb 14, 2015
    Posts:
    6
    A button I have made won't work and I don't know why. I did the usual UI text element then added a button component. I have wired my main menu to go a options menu and that works fine but then when I switched the button in the options menu to go back to the main menu the button won't work. I know my script is working because the buttons in the main menu work fine. The function I've used to go from one level to the next, takes a string and I know that I didn't misspell the level. Any ideas or suggestions on what to do would be welcomed.
     
  2. tedthebug

    tedthebug

    Joined:
    May 6, 2015
    Posts:
    2,570
    You could put a breakpoint into the button script & then step into the code to see what's happening.
     
  3. LHarris134

    LHarris134

    Joined:
    Feb 14, 2015
    Posts:
    6
    There's no real walking through the code since my function is only 2 lines:

    publicvoidLoadLevel(stringname)
    {
    Debug.Log ("Level Load Requested for: " + name);
    Application.LoadLevel (name);
    }

    this function takes in the name of a scene and displays it to the console as well as loading the level. My problem is that the button doesn't even act like a button. It acts like there is nothing to click. Like the button doesn't exist. I've tried different kinds of buttons it still doesn't work. I don't know what the problem could be but i just deleted the scene and now it seems to work. Go figure. Thanks for the suggestion though.
     
  4. Munchy2007

    Munchy2007

    Joined:
    Jun 16, 2013
    Posts:
    1,732
    Maybe the scene didn't have an EventSystem in it.