Support => NGUI 3 Support => Topic started by: Fireball14 on July 01, 2014, 09:46:21 AM
Title: MissingReferenceException inside NGUI
Post by: Fireball14 on July 01, 2014, 09:46:21 AM
MissingReferenceException: The object of type 'UILabel' has been destroyed but you are still trying to access it. Your script should either check if it is null or you should not destroy the object. UnityEngine.Component.get_transform () (at C:/BuildAgent/work/aeedb04a1292f85a/artifacts/EditorGenerated/UnityEngineComponent.cs:20) UIRect.get_cachedTransform () (at Assets/NGUI/Scripts/Internal/UIRect.cs:196) UIRect.get_parent () (at Assets/NGUI/Scripts/Internal/UIRect.cs:239)
I get this randomly after updating to 3.6.6 Edit: (and on 3.6.4(did not get it yet on 3.6.6)). Also i get (randomly) similar errors on UItween components.(il add trace when next time i get this on UItween)
Title: Re: MissingReferenceException inside NGUI
Post by: Fireball14 on July 01, 2014, 10:26:09 AM
Ok traced this error to this code: Label.gameObject is turned off on Start.
void Awake()
{
BattleMain.OnEquationChange+= OnOnEquationChange;//<- Activates while Label.gameObject is not active, so i think this is what causing problem. Still need to do some testing.
}
privatevoid OnOnEquationChange()
{
Label.text="2+2";
}
Title: Re: MissingReferenceException inside NGUI
Post by: Fireball14 on July 01, 2014, 12:07:17 PM
Ok i think i found problem. Before 3.6.6 this did not meter. But on 3.6.6 you cant send two same events on same object in one update. I dont know why =\ But removing one of event senders fixes problem. Il test more tomorrow, but for now 1 hour testing confirmed this.
Title: Re: MissingReferenceException inside NGUI
Post by: ArenMook on July 02, 2014, 04:00:51 AM
Never use Awake for anything other than initializing local script's values.
Read up on what Unity is intended Awake for. It's basically the constructor, called before the hierarchy and other scripts are processed.
Title: Re: MissingReferenceException inside NGUI
Post by: Fireball14 on July 02, 2014, 06:50:06 AM