Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: pad406 on February 05, 2014, 10:56:52 AM
-
I'm trying to change a sprite at runtime via a script. I change the UISprite.spriteName to what I want, and I can see them changed in the inspector. However, the sprite is not being displayed. If I pause the game and manually select the same sprite name from the Atlas, then un-pause the game, it has updated. I've tried various combinations of .MarkAsChanged() .Update() to no avail. Any ideas on what I'm missing
thanks
Paul
-
Setting UISprite.spriteName is all you have to do, no need to call MarkAsChanged. That's what the UIImageButton script does as well. So what you're seeing is that it changes in inspector, but does not change in the game window? Can you post some code of what you're doing?
-
Hi Aren
I've got it working, but I'm not sure why. For some reason I decided to try doing a .Trim() on the name when I set it and it works. I have checked via Debug.Log and my usual ">" + stringName + "<" and there's no spaces to be trimmed. I'm going to dig a bit more into it and if I find anything that may be of interest I'll post another reply.
-
Trim() removes more than just spaces. Tabs, new line characters, other invisible characters... Try printing the before and after length.
-
Yup, carriage return at the end.