- Home /
How dose Xml Sparrow Work?
so i have an xml subtexture
>SubTexture name="name" x="1627" y="0" width="223" height="226" frameX="-1" frameY="-3" frameWidth="226" frameHeight="230"<
and i know how to use the "x,y,width,hight" but
the "frameX,frameY,frameWidth,frameHIght" i dont know how to use them
i tried some things. but it dosn't work on every one
How to use them?
Answer by Bunny83 · May 17 at 02:05 PM
Well, it seems to be documented over here:
Texture Frame
If your images have transparent areas at their edges, you can make use of the frame property of the Texture class. Trim the texture by removing the transparent edges and specify the original texture size like this:
There are more details on the Texture documentation. So it seems that the texture actually occupies 10x10 pixels on the atlas and in the case specified here there is a 10 pixels border around the image which should make the image appear as if it's 30x30. That "frame" is essentially placed relative to the texture around the texture.
In your case there would be a 1 pixel border on the left edge, a 3 pixel border on the top edge, a 2 pixel border on the right edge and a 1 pixel border on the bottom (assuming 0,0 is top left. If it's bottom left, of course top and bottom would be flipped around).
You ask how to use them, but you haven't said what you want to do in the first place.
after a lot of test i came up with this code
Rect ProcessRectAngle (RectInt ToProcessRectangle)
{
Vector2 pos = ToProcessRectangle.position;
Vector2 size = ToProcessRectangle.size;
if(pos.x == 0 && pos.y == 0)
{
return new Rect(pos,size);
}
if(pos.x != 0)
{
size.x -= Mathf.Abs(pos.x);
pos .x = -(pos.x / 2f);
}
if(pos.y != 0)
{
size.y -= Mathf.Abs(pos.y);
pos .y = pos.y / 2f;
}
return new Rect(pos,size);
}
thanks a lot
i want to do an easy animator using the data given in the xml
Your answer
Follow this Question
Related Questions
Learning to move 1 Answer
Rig object offsets during animations 0 Answers
Make mecanim not affect transform? 2 Answers
Animation affecting transform problem 0 Answers