ckfw a écritAh, thank you very much Harold. This helped! It's still a bit awkward for me to do this in Unity, how I have to make a parent object just to scale then have a child object with the attached script to do two tasks. I was hoping I could adjust with just one game object with the script attached.
As mentioned, you can adjust the Pivor of the Sprite if you don't want to use an additional GameObject.
ckfw a écritSorry, I am not quite knowledgeable in the differences between UV coords and vertex position to know exactly what you're trying to say.
Vertex position determine where the triangle will be, where each vertex (=corner) of your triangle is positioned in the world. UV coordinates determine where the texture is placed on these fixed corners and edges of the triangle. It is similar to an "invisible" table and a colored table-cloth on top - the vertices determine the corners of the table surface, and the UV coordinates say where an elastic piece of table-cloth is wrapped over this table surface.
ckfw a écritCode I used. I am not entirely sure why it's not giving me the same results, it keeps scaling the images differently than what it's animated to look like. Below is also another code I have used.
..
The Sprite I am using has the exact same file size, but it is not entirely the exact same sized or designed sword. The examples I see on Spine are using them like skins, but I want to use different sized swords and equips and not use them as a skin.
The GetRemappedClone
method provides the parameter useOriginalRegionSize
, which defaults to false
, as can be seen here in the code. From the documentation:
useOriginalRegionSize: If true the size of the original attachment will be followed, instead of using the Sprite size.
This parameter only has an effect if using RegionAttachments
(Attachments that don't have the Mesh
option enabled in Spine). The parameter has no effect when using MeshAttachments
where the mesh is never scaled larger or smaller (which would never produce the desired results). In your code you left the useOriginalRegionSize
parameter at the default value of false
, meaning that the new Sprite's size will be used. If you would set the parameter to true
, then the original region width and height will be maintained, and filled with the new Sprite, which will be distorted to fit if it's of different size.
If you are receiving slightly different scaling although the Sprite is the same as the image used in Spine, did you perhaps enable Strip Whitespace X/Y
when exporting the atlas from Spine? This will remove any blank transparent area. So if your Sprite contains a lot of whitespace, the mapping might be slightly different, to enclose the whitespace. Admittedly this would be nice to be compensated automatically by the GetRemappedClone
method. If this is the problem, then we could add another function argument so that whitespace stripping is compensated for. Could you please have a look if you have enabled Strip whitespace
and if the remapped Sprite is smaller by the size of the whitespace in the Sprite? You can also post a screenshot of the Sprite and the character before and after remapping attachments, if you prefer that.
Another reason might be the scale
parameter of the GetRemappedClone
method, which is also left at the default of 0.01
. This would yield different results when your _SkeletonData
asset has the Scale
set to something different than 0.01. However I assume that this is rather not the problem.