Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: dark_tonic on September 06, 2012, 10:31:26 AM
-
I've had a look through previous posts and done a couple searches and couldn't find this issue.
I have an atlas of sprites created through TexturePacker
I need to make a single sprite face left and face right.
With a basic UISprite, if I set scale x to -1 (or other value) the sprite disappears, so I can't use the flipped version.
I've tried adjusting Z and the UISprite depth function, but it doesn't appear to be a sorting issue.
Other sprites from this same atlas also need to appear in the scene simultaneously.
Thoughts?
-
I'm pretty sure that scale <= 0f results in a NaN (not a number) calculation within NGUI.
You could likely code a function to build these mirrored textures at startup time, by just using Texture2D and Get/Set Pixels. Get them in horizontal or vertical 1-pixel-wide blocks and Set them in the target mirrored texture object.
However, this would mean that the texture is no longer in an atlas, so it wouldn't draw in one call any longer. You'll likely have to have both versions of the sprite in your atlas.
-
I use negative scaling in a bunch of places to mirror sprites, so it's definitely possible.
-
Ditto, I mirror the sprite by specifying a negative scale in Windward in a couple of places, works fine. I generally prefer to rotate it 180 degrees instead though.
The sprite will only disappear with a flipped scale if you're using some shader that does backface culling. NGUI shaders don't, by default.
-
thanks, everyone!
Yeah, I was using unlit / transparent for the shader. ::) I set it to a different transparent shader and it's all working correctly. ;D
-
Heh. I am becoming educated one correction of an incorrect assertion at a time!