Author Topic: Calling script with null parameter = null reference  (Read 5094 times)

Ludopathic

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 11
    • View Profile
Calling script with null parameter = null reference
« 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.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Calling script with null parameter = null reference
« Reply #1 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

Ludopathic

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 11
    • View Profile
Re: Calling script with null parameter = null reference
« Reply #2 on: December 31, 2016, 08:01:52 AM »
You would think so wouldn't you -

  1.  LoginPro.Manager.ExecuteOnServer("GetNickname", GetFromServer_Success, GetFromServer_Error, null);

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.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Calling script with null parameter = null reference
« Reply #3 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.
  1. Debug.Log(LoginPro.Manager != null);

Ludopathic

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 11
    • View Profile
Re: Calling script with null parameter = null reference
« Reply #4 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.