Support => NGUI 3 Support => Topic started by: Ludopathic on December 31, 2016, 06:46:04 AM
Title: Calling script with null parameter = null reference
Post by: Ludopathic on December 31, 2016, 06:46:04 AM
HI there, I am calling a script method from a button using onclick notify - the method has a null parameter and these parameters/methods serve to instruct my networking code to pull information from my server. However when I click the button I am getting a null reference exception with reference to the line I am trying to call, citing further errors in event delegate.
System.NullReferenceException: Object reference not set to an instance of an object at GetDataTest.GetFromServer () [0x00024] in D:\dropbox\Dropbox\MOBA project\New MOBA\Assets\_Menu\GetDataTest.cs:17 at EventDelegate.Execute () [0x00039] in D:\dropbox\Dropbox\MOBA project\New MOBA\Assets\NGUI\Scripts\Internal\EventDelegate.cs:476 at EventDelegate.Execute (System.Collections.Generic.List`1 list) [0x00020] in D:\dropbox\Dropbox\MOBA project\New MOBA\Assets\NGUI\Scripts\Internal\EventDelegate.cs:644 at UIButton.OnClick () [0x00041] in D:\dropbox\Dropbox\MOBA project\New MOBA\Assets\NGUI\Scripts\Interaction\UIButton.cs:248
Can someone advise?
I'm a little annoyed. This is not the first time that I have found NGUI to throw errors whilst attempting to use basic functionality.
Title: Re: Calling script with null parameter = null reference
Post by: ArenMook on December 31, 2016, 07:50:34 AM
The error is in your code: GetDataTest.GetFromServer. I'm not sure why you're blaming NGUI in this case as it's pretty clear where the null exception happens, and it's not in it. o_O
Title: Re: Calling script with null parameter = null reference
Post by: Ludopathic on December 31, 2016, 08:01:52 AM
This is the line that apparently has a null reference. Script exists, the parameters are correct and work fine in another scene using Unity UI. Figure that one out genius.
Title: Re: Calling script with null parameter = null reference
Post by: ArenMook on December 31, 2016, 08:09:25 AM
Insulting me won't help me help you.
Add a Debug.Log on top of your line.
Debug.Log(LoginPro.Manager!=null);
Title: Re: Calling script with null parameter = null reference
Post by: Ludopathic on December 31, 2016, 08:21:01 AM
I got :
True UnityEngine.Debug:Log(Object)
I deleted NGUI and reimported it and the damn thing works fine now despite having done this 3 times in the last 24 hours. I apologise for my temper, I am just annoyed at the amount of lost hours due to this issue.