Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: spflan on January 21, 2014, 08:21:36 PM

Title: UI2DSprite Issue
Post by: spflan on January 21, 2014, 08:21:36 PM
I'm having a problem that occurs intermitently. Sometimes a UI2DSprite loads the wrong sprite. This seems to happen randomly, so I'm having difficulty pinning down the problem. I've attached a screenshot that shows my scene running. There are 2 UI2DSprites in the scene. I have one of them selected by the Inspector, which shows that it is displaying the wrong sprite. Any ideas what could be causing the problem?
Title: Re: UI2DSprite Issue
Post by: ArenMook on January 22, 2014, 02:12:06 AM
What changes the sprite, and how does it change it?
Title: Re: UI2DSprite Issue
Post by: spflan on January 22, 2014, 09:10:35 AM
That's what I'm trying to figure out. The sprite itself doesn't get changed. The sprite's gameObject moves in & out of the camera view using a .anim file animation. I'll record a quick video and post it shortly.
Title: Re: UI2DSprite Issue
Post by: spflan on January 22, 2014, 09:47:26 AM
Okay, I uploaded a video showing the issue to youtube: http://youtu.be/10zXOWwhhIw (http://youtu.be/10zXOWwhhIw).

In this video I start & stop the playback of a Unity scene multiple times. Each time should show the same sprites in the same order, but that's not what happens, as you are about to see.

I have 4 UI2DSprites that animate in & out through .anim files. Each UI2DSprite has a unique 2D Sprite attached to that gameobject. However, when I play back the scene, when 2 of the 2D sprites are shown at the same time, Unity will "randomly" use the same 2D Sprite for both of the sprites. I put "randomly" in quotes because I can't believe it to be truly random, which is why I am posting here for some help.

Cheers
Title: Re: UI2DSprite Issue
Post by: spflan on January 22, 2014, 10:13:36 AM
One quick additional note. I'm using NGUI 3.0.6 f7 on Unity 4.3.3f1.

I made a copy of my project and tried upgrading it to NGUI 3.0.9, but it messed up some of my UILabel's & associated code, as well as causing strange color issues when using TweenPosition on a UISprite that has a widget color added to it. It also didn't fix this UI2DSprite issue, so I went back and read through all the changes & fixes made to NGUI since 3.0.6 f7. None of them appeared to offer any solution to my UI2DSprite problem, so I went back to my original project with NGUI 3.0.6 f7.
Title: Re: UI2DSprite Issue
Post by: spflan on January 22, 2014, 07:29:55 PM
Quick update:

I didn't figure out what was causing the problem, but I ended up writing some functions to animate the sprites with TweenPosition & TweenAlpha instead of .anim files, and now the sprites are showing up & animating correctly.

I'm still curious as to what was causing the problem, but it's no longer an urgent matter to me. If I end up figuring out the root cause, I will post back here with another update.