Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: PoN on October 08, 2012, 10:33:45 PM
-
Pls ,Tell me how can i do that, create atlas by NGUI Atlas Maker and use "rotation" feature of Texture Packer ? thx
-
I think it doesn't support it yet.
-
Yeah, in NGUIJson.LoadSpriteData, there is a comment:
// TODO: Account for rotated sprites
NGUI currently imports the rotated sprite's UVs correctly; it doesn't rotate the sprite correctly when it is created, though.
-
This is a request feature then :)
ArenMook is this something really hard to do ? Don't we just have to rotate the sprite ?
This will be something really great !
-
Hard? Nah. But this feature is requested once in a blue moon (the last time was in February I think?), so I didn't look into it.
-
Héhé, well I'm thinking about switching every atlas generation with TexturePacker so that would be great
-
Send me an atlas that has a rotated sprite in it then. Do that on the 12th though, as I don't return until then.
-
I've just sent you an email, that you'll find on the 12th ;)
Thanks !
-
Hi,
Just a reminder, should I send you another email ?
-
No, I have it saved. Just haven't gotten around to it yet.
-
I would also like to see this feature, Texture packer has the MaxRects Algorithm which place 20% more sprites on the same Atlas, and having NGUI to support to orientation (+90 or -90 degrees) would be a very nice addition.
Best
-
+1 for that feature...
-
+1
-
I have to cry like the rest :P +1 for this feature
-
+1 for this feature.
Especially, with NGUI rolling your own texture packer you could use that to rotate the sprites for the optimal placement on the sprite atlas, and/or import the rotated sprites from TexturePacker output. I understand if it doesn't get done as this would probably impact a significant number of widgets to maintain the offset and rotational value of the sprites and then do and undo that transform when performing calculations.
-
I just had a quick go at this (going through my whole HUD to fix items that had changed rotation every time I re-packed the textures was really getting on my nerves). My solution seems to work fine, and is pretty easy. No guarantees though - it's likely I've missed something somewhere...
Anyway, a brief summary of my changes:
NGUIJson.cs:
Just under
bool rotated = (bool)table["rotated"];
add
newSprite.isRotated = rotated;
UIAtlas.cs
Under
public bool hasPadding { get { return paddingLeft != 0f || paddingRight != 0f || paddingTop != 0f || paddingBottom != 0f; } }
add
public bool isRotated;
UISprite.cs
Under
float pixelSize = atlas.pixelSize
add
if (mSprite.isRotated)
{
float tmp = rect.width;
rect.width = rect.height;
rect.height = tmp;
}
Replace
uvs.Add(uv1);
uvs.Add(new Vector2(uv1.x, uv0.y));
uvs.Add(uv0);
uvs.Add(new Vector2(uv0.x, uv1.y));
with
if (!mSprite.isRotated)
{
uvs.Add(uv1);
uvs.Add(new Vector2(uv1.x, uv0.y));
uvs.Add(uv0);
uvs.Add(new Vector2(uv0.x, uv1.y));
}
else
{
uvs.Add(new Vector2(uv1.x, uv0.y));
uvs.Add(uv0);
uvs.Add(new Vector2(uv0.x, uv1.y));
uvs.Add(uv1);
}
That should be it!
ArenMook - if this looks OK to you, any chance you could drop it into the next version? I'd hate to have to merge it in every time.
Cheers!
Rob.
-
Absolutely. Just keep in mind this wont affect sliced sprites or filled sprites. Just regular sprites.
-
@RobD: Thank you! Great help to squeeze the last few sprites into a tight ram budget. Would love to see this in the full version.
-
Any updates on this? I still can't see it in the Pro version.
-
Interesting to me too, Up
-
I'm curious as well on what the status is on this? More so if i can use Texture Packer to generate my atlases and if so how do i import them for use with NGUI?
I'd love to use the rotate feature, it makes my textures oh so small!
-
From what I remember the posted code drew rotated sprites in the wrong order (back-faced) resulting in the sprite being inside-out. That combined with the fact that it only handled regular sprites, and not sliced, filled, or tiled sprites created too many inconsistencies for me to add it as-is.
-
Is there a specific reason why the custom packer doesnt rotate sprites?
-
Nothing does. Only TexturePacker rotates sprites, if enabled.
-
Yup, I'm using TexturePacker with NGUI and it's much more powerful (no offense) than the one in NGUI :)
-
Hi, I just make some modify to UISprite and make it possible to use rotated sprite in Simple / Sliced / Tiled / Filled type. :D
I attached the patch file and if any problem please let me know :)
-
Nice. You even #ifdef'd the whole thing -- that's useful, thanks.
-
Sounds awesome. Can i apply the patch myself somehow or should i wait for an update?
-
Can't apply it as-is unfortunately as splash is either not a Pro user or didn't use the pro repository, so revision numbers don't match.
-
Is the #if flag set through the atlas information from TexturePacker? the patch file looks pretty straight forward. Guess i should test in an empty project.
-
If you use NGUI 2.6.3, you can apply this patch to UISprite.cs. I think it should work well.
Use of #if ... #endif is a way to change code back to original behavior when I test rotated sprite.
-
I tried it with 2.6.3 and no luck. You likely have a custom repository (perhaps containing your game code?) and it uses version numbers from there. You are not using the NGUI's Pro repository.
-
I don't know if I'm allowed to attach entire UISprite.cs on forum. :-\ ...
And I tried patch UISprite.cs from 2.6.3 NGUI package and works ok.
-
Do not post NGUI code in the form.
Send a email to support at tasharen.com with UISprite.cs attached.
-
Individual files are just fine, Malzbier.
-
Any news about this feature? I think it is really important. When you are constrained to a POT Texture, it could reduce to a half the amount of memory required for an atlas.
-
+1 Supporting rotated sprites in texture packer would have made my life a lot easier!
-
Here is the UISprite.cs I modified for rotated sprite.
Base on 2.6.5b.
If any problem please let me know.
-
Anybody did this for NGUI 3? Looked a bit into it but there is a lot of changes :(
-
+1, Up up up. So what's about a rotation feature in NGUI 3 ?
-
Did this ever make it into the repository ?
-
I don't believe so.
-
I´ll take a stab at merging that patch into the pro repo when I have time
-
Have you had the time to give it a shot?
-
+1 Supporting rotated sprites in texture packer.