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

"Object reference not set to an instance of the object" (no directory to faulty code)

Discussion in 'Editor & General Support' started by PrecentralGyrus, Sep 13, 2014.

  1. PrecentralGyrus

    PrecentralGyrus

    Joined:
    Sep 13, 2014
    Posts:
    6
    So I am building my first project in unity using 4.6. I have followed a simple tutorial to get a button in 4.6 to load a level, but now for some reason the code has broken.

    Basically as a template I copied this script from the video into my code:

    public void ChangeToScene (int sceneToChangeTo)
    {
    Application.LoadLevel (sceneToChangeTo);
    }

    I then assigned this script to a controller, and assigned the controller to the "on click" menus. This used to work fine, but now when I try to open the drop down function menu, it throws the above error. It doesn't give a reference to any bad code, nor does it tell me what's wrong. It used to work, but now it does not. Does anyone know why it is throwing this error?
     
  2. PrecentralGyrus

    PrecentralGyrus

    Joined:
    Sep 13, 2014
    Posts:
    6
    Does anyone know, or do I need to provide more information about my issue? I'm sorry for the bump, I would just really like to get working again on my project and I rely fairly heavily on buttons. I am also new to Unity, so I am under the assumption that this is my own fault, and not a fault of the program...
     
  3. Suddoha

    Suddoha

    Joined:
    Nov 9, 2013
    Posts:
    2,824
    It might be helpful to see the piece of code which calls the function, because there's nothing wrong with the code you posted. And please use code tags when posting code snippets.