Hi,
looks like
I am using NGUI wrong some bugs were introduced in recent versions of NGUI. I am not sure, but it seems it started with v3.0.x. I until recently had 3.0.6 f5, just updated to 3.0.8 f4 and the problem remains. In 3.0.x < 3.0.6 this problem did not exist. I can't give you some conclusive theory on what happens, only a few hints.
Again, I am not 100% sure, but it seems the problem started when I started using UIStretch to stretch a screen fader GameObject (a fader covering the screen for a fade in/out effect). The effect works fine now and without errors in v3.0.x y 3.0.6, but on the console I now often get an error a la:
UnassignedReferenceError
: Variable mTrans of UIStretch
is not assigned
.
The variable UICamera of the UIStretch component is assigned (the Unity3D standard camera), the container variable is not. Is has worked fine until recently. I
assume because of this, the console also says things like:
Some objects were not cleaned up when closing the scene
. (Did you spawn
new GameObjects
from OnDestroy
?)
(I don't use OnDestroy anywhere in my own code) and the infamous:
!IsPlayingOrAllowExecuteInEditMode ()
As a result, the
_RealTime object remains in the scene and accumulates on Play tests (i.e. five _RealTime objects in the scene after five Play tests). This (again, I assume) is responsible for errors I get when I deactivate a button OnClick that has a hover effect that changes the button color.
EDIT:
I get the IsPlayingOrAllowExecuteInEditMode error by simply extending the UIPanel component in the inspector of any GameObject, if the _RealTime object remains in the scene.
Interestingly, NGUI also sometimes keeps the fader GameObject
activated after a Play test, where it is always
deactivated by default. This does not always happen, but often enough so that a manual deactivation on my part becomes frustrating. The fader has a TweenAlpha component, which interestingly sometimes gets a OnFinished Event assigned automatically (which happens nowhere else in my scene, though I use a lot of TweenAlphas).
I am relatively sure NGUI is to blame for all this since it did work with v3.0.x < v.3.0.6.
EDIT:
Scratch that. It seems the UIButtonColor error:
NullReferenceException: Object reference not set to an instance of an object
UIButtonColor.OnPress (Boolean isPressed) (at Assets/NGUI/Scripts/Interaction/UIButtonColor.cs:152)
UIButton.OnPress (Boolean isPressed) (at Assets/NGUI/Scripts/Interaction/UIButton.cs:90)
UnityEngine.Component:SendMessage(String, Object, SendMessageOptions)
UIKeyBinding:Update() (at Assets/NGUI/Scripts/Interaction/UIKeyBinding.cs:112)
is something else. I have buttons in my scene that are activated either via mouse click or via a key press (UIKeyBinding component). When I click the button, I get no errors. When I use the key press, I do get the above error. The way my buttons work is that they deactivate themselves (actually their parent, which holds all that kind of buttons) when being pressed to avoid multiple presses. This kind of setup has worked probably since I use NGUI, it started throwing errors just recently. This behavior happens no matter how many _RealTime objects there are in the scene.