- Home /
Question by
gregalbing · Apr 20, 2016 at 05:10 PM ·
button trigger eventsnull reference exceptionunexpected
Wrong value when method called from a button
This has been driving me nuts - I've got a public reference that is assigned in the editor. Normally, it's not null and behaves correctly. However, when the method "okay" is called by pressing a button, the reference is null. What is going on? Is this some editor magic that I'm not aware of? I'm using 5.1.1f1; was this a known issue with this version?
Thanks so much for any help!
using UnityStandardAssets.Characters.FirstPerson;
public class OptionsData : MonoBehaviour {
public FirstPersonController mouseInfo;
void Update()
{
Debug.Log (mouseInfo == null);
okay ();
}
public void okay()
{
Debug.Log (mouseInfo == null);
}
}
Comment