Search Unity

[Delete]

Discussion in 'Scripting' started by nbg_yalta, Oct 21, 2017.

Thread Status:
Not open for further replies.
  1. nbg_yalta

    nbg_yalta

    Joined:
    Oct 3, 2012
    Posts:
    378
    I've a Text variable assigned in inspector, but it gives me a null reference exception, why???
     
  2. Suddoha

    Suddoha

    Joined:
    Nov 9, 2013
    Posts:
    2,824
    You defintely have 2 instances in your scene.

    That would not only be my first guess, but the output indicates that as well. It prints the minus once and throws, the second instance is the one you showed in the inspector.

    Do one of the following:
    1) Debug.Log(gameObject.name) in that script
    2) Use the scene hierarchy's search field and type "t:GameManager". It'll highlight all the objects that have such script attached to it.
     
  3. nbg_yalta

    nbg_yalta

    Joined:
    Oct 3, 2012
    Posts:
    378
    oh you managed to answer, yes that's the case, realized this is possible just after making this post :D
     
  4. Suddoha

    Suddoha

    Joined:
    Nov 9, 2013
    Posts:
    2,824
    Kind of - almost. When I hit the post reply button, you had already figured it out. :p
     
Thread Status:
Not open for further replies.