- Home /
Text Color Null Ref
This is a strange issue--maybe it's a bug with unity?
I've set up a crossfade for some text.
IEnumerator FadeSwap(string newText) {
Color c = lbl.color;
Color t = c;
t.a = 0f;
lbl.CrossFadeColor(t,fadeTime,false,true);
yield return new WaitForSeconds(fadeTime);
lbl.text = newText;
lbl.CrossFadeColor(c,fadeTime,false,true);
}
lbl is my text object linked through the inspector--it's most definitely not null. I can print the name, etc. In fact--this code does exactly what I want it to do.
But it throws an error!
NullReferenceException: Object reference not set to an instance of an object
PlayerTurnNotifier+<FadeSwap>c__Iterator12.MoveNext () (at Assets/Scripts/GUI/PlayerTurnNotifier.cs:48)
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
PlayerTurnNotifier:PlatPhase(GameAction) (at Assets/Scripts/GUI/PlayerTurnNotifier.cs:39)
Game:Raise(GameEventArgs, GameAction) (at Assets/Scripts/Game/Game.cs:185)
<MalevolenceInc>c__Iterator14:MoveNext() (at Assets/Scripts/Game/Game.cs:279)
I get this error wherever I try to reference the color of the text object. It looks like it's screaming about some sort of coroutine mumbo jumbo but that doesn't seem to be the case. Any thoughts about what I may have missed?
Comment
Best Answer
Answer by Wuzseen · Jan 02, 2015 at 10:15 AM
I restarted Unity and the issue went away. Wild.