Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Sermolux on May 17, 2016, 12:36:23 AM

Title: UICamera events are referencing objects in previously loaded scene.
Post by: Sermolux on May 17, 2016, 12:36:23 AM
Hi,

I'm having an issue using UICamera.onClick as a catch all. When I first start the app it behaves as expected, but when I load a new scene I get a MissingReferenceException. I believe that the onClick event is still looking for the object in the previous scene. This happens for all events through UICamera. I find that if I set UICamera.onClick to null just before I load a scene everything works. Am I using this incorrectly?
Title: Re: UICamera events are referencing objects in previously loaded scene.
Post by: ArenMook on May 18, 2016, 05:03:07 AM
You need to register it in the script's OnEnable, and unregister in OnDisable. I'm guessing you don't do the unregistration part, so yes of course you get an exception.