I’m trying to write a simple sprite animation system for 2D on the GUI layer and am running into problems with GUI.DrawTextureWithTexCoords. I have a sprite sheet that’s 32x256px at 32x32 per sprite (ie. 1x8 sprites), but no matter what I set the texCoords Rect to I can’t seem to get any of them to display.
Rects I’ve tried for texCoord:
(0, 0, 32, 32)
(0, 32, 32 ,32)
(0, -32, 32, 32)
(0, 0, 256, 32)
All of these give me the same result - if alphaBlend is true, I will always get a white square at near-full transparency, if alphaBlend is false, I will just get a white square.
Replacing DrawTextureWithTexCoords with DrawTexture gives me the full spritesheet squashed down to 32x32, but works fine otherwise.
Has someone successfully used GUI.DrawTextureWithTexCoords and can explain how the texCoords Rect works?
(timesx, timesy) is a thing that says how many times Unity must draw the texture.
In the example below (tx, ty) = (2.5, 1.5) (and (x, y), obviously = (0,0))
[87876-q31hcdkuiwa-копия.jpg|87876]
And here is an example that uses both pairs of parameters:
UP: in the comments
PS Sorry for images, I’m not a good artist actually
Well, only 2 pictures are allowed, and I can't attach more in comment somehow. So I leave a link to the 3d picture here http://imgur.com/rjxvPsT
That is indeed perfect. Thanks a lot!
– anon4311011I have been trying to solve this problem; the documentation was not very clear. Thank you so much!
– Mentalist4006can't up vote, so +1
– Martin_Coll