2D Toolkit Forum
2D Toolkit => Support => Topic started by: ryf9059 on May 27, 2013, 05:06:15 am
-
This is gonna be a long story.
So basically I'm trying to use spine (the skeleton tool under progress, see: http://esotericsoftware.com/) with 2dtk in unity. You probably know spine since the developer said he has discussed things with you regarding the integration before. And I'm having a problem scaling with the skeletong by adjusting the orthosize and target height in sprite collection editor (I'm not using 2DTK camera by the way)
I have already seek support from spine forum but didn't get much luck, still a long story. Please read this link first to get an idea of the situation.
http://esotericsoftware.com/forum/viewtopic.php?f=3&t=713 (please read it carefully as it contains a lot of information, you might go back to look this link if you see things I mentioned before that you need to get a context with)
After reading this you now know I'm having a werid problem that others didn't encounter, and the rebuilding index problem which I have file a report to unity. I don't know if this maybe something 2dtk can help with. You can try downloading the 2dtk runtime on github page: https://github.com/EsotericSoftware/spine-runtimes and create a example to see if the scaling works. From the post you can tell they have committed a new example but that still didn't work for me and my example simple don't show skeleton for them, which confuses me. I have send 2 zip folders to your support email, one is the old project i have (created from scratch tho), another is their newly commited example. Does these two works for you about scaling? What unity version are you using? I'm using 4.1.2f and this is my last resort of seeking help. I'm been stuck on this for more than a week and I need to get a demo done in a month, very urgent.
Please investicate this issue and see if there is anything you might be able to help.
Thanks
-
There is an issue with Unity 4.1.x and 2D Toolkit 1.92 final.
Update to the 1.92 + patch 1 to fix the issue with the progress bar.
After updating, restart unity, and 2D Toolkit > Rebuild Index. You should be able to create sprites, etc. after that.
Please check the releases forum after updating Unity etc. Unity can and often break things which we rely on without warning - but we post fixes as soon as we find/resolve em.
-
There is an issue with Unity 4.1.x and 2D Toolkit 1.92 final.
Update to the 1.92 + patch 1 to fix the issue with the progress bar.
After updating, restart unity, and 2D Toolkit > Rebuild Index. You should be able to create sprites, etc. after that.
Please check the releases forum after updating Unity etc. Unity can and often break things which we rely on without warning - but we post fixes as soon as we find/resolve em.
(http://i.imgur.com/A4P0f9a.png)
This is all I see from the update window, I can't find 1.92+ patch, only a few beta patches
(http://)
-
Maybe it wasn't updated and/or lost during the server migration. You can get it here. Its on this forum.
http://unikronsoftware.com/2dtoolkit/forum/index.php/topic,1398.0.html
-
Maybe it wasn't updated and/or lost during the server migration. You can get it here. Its on this forum.
http://unikronsoftware.com/2dtoolkit/forum/index.php/topic,1398.0.html
I just updated, I imported both 2dtoolkit1.92final_patch1.unitypackage and 2dtoolkit1.92final_patch1_src.unitypackage. After importing I restarted unity and rebuilt index, but it didn't solve my problem. After i change the atlas unity still keeps rebuilding the index.
This video shows the bug I'm experiencing. It is recorded before the update, but they behave exactly the same.
http://screencast.com/t/K12z5fTcJi
-
I saw the video, and I saw it in your project. I upgraded, rebuilt index and it works fine for me now in your project. You know, where you have the spineboy tk2d Skeleton and the child sprite, changing it to the spineboy atlas actually does work fine.
I've emailed you a zip of the project which works.
-
I saw the video, and I saw it in your project. I upgraded, rebuilt index and it works fine for me now in your project. You know, where you have the spineboy tk2d Skeleton and the child sprite, changing it to the spineboy atlas actually does work fine.
I've emailed you a zip of the project which works.
It worked for me now as well, thanks. But why is that? Do I need to delete the old 2dtk folder before upgrading? I just imported them.
Plus, this didn't not solve the problem of changing ortho size tho, the spineboy size keeps unchanged.
-
You don't need to delete before upgrading. Not sure why it worked for me and not you, but it works now ;)
I don't know about the ortho size with the spineboy - I didn't write the Spine integration code, so I couldn't really help you with that. I think its removing the ortho size scale from the sprites themselves, but I couldn't tell you that for certain. Probably best to speak to the author of the integration.
-
You don't need to delete before upgrading. Not sure why it worked for me and not you, but it works now ;)
I don't know about the ortho size with the spineboy - I didn't write the Spine integration code, so I couldn't really help you with that. I think its removing the ortho size scale from the sprites themselves, but I couldn't tell you that for certain. Probably best to speak to the author of the integration.
Because the scaling works for them but not me :( I already asked the developer of spine and the scaling was working for them.
I hate this kind of bug, not sure if this is because of a unity problem.
-
You don't need to delete before upgrading. Not sure why it worked for me and not you, but it works now ;)
I don't know about the ortho size with the spineboy - I didn't write the Spine integration code, so I couldn't really help you with that. I think its removing the ortho size scale from the sprites themselves, but I couldn't tell you that for certain. Probably best to speak to the author of the integration.
Because the scaling works for them but not me :( I already asked the developer of spine and the scaling was working for them.
I hate this kind of bug, not sure if this is because of a unity problem.
No, it doesn't. The skinned sprite created by the spine integration doesn't use the scale, just the UVs from the atlas. Just tick Use tk2dCamera in the sprite collection and the sprites will then be the same size.
-
No, it doesn't. The skinned sprite created by the spine integration doesn't use the scale, just the UVs from the atlas. Just tick Use tk2dCamera in the sprite collection and the sprites will then be the same size.
But I remember there is a bug with unity for 2dtk camera in which it only shows part of the game view? I remember I even made a post in this forum about this. (http://unikronsoftware.com/2dtoolkit/forum/index.php/topic,1481.msg7131.html#msg7131)
Since it's inconvenient with that perspective and I'm not used to it that's why I decide to just use normal camera and enter the ortho size and target height instead. And I might also need to change the camera size in the game later so another reason not to use 2dtk camera. But presumably this two cameras should work the same as long as the correct target height and ortho size is entered isn't it? The Spine authore said both camera works for him
-
Both work, you just have to set the sizes correctly.
With the tk2dCamera, there is a special preview window which shows you the correct preview. The bug in Unity should be fixed in 4.2 and the normal camera preview should appear correct in there too.
At the end of the day its just down to scales. With a normal ortho camera to get the same scale as a tk2dCamera, set the ortho size in the camera to the half the resolution height. Eg. for 1024x768, set it to 384.
Or for a normal camera, take the spine sprite and scale it down appropriately.
-
Both work, you just have to set the sizes correctly.
With the tk2dCamera, there is a special preview window which shows you the correct preview. The bug in Unity should be fixed in 4.2 and the normal camera preview should appear correct in there too.
At the end of the day its just down to scales. With a normal ortho camera to get the same scale as a tk2dCamera, set the ortho size in the camera to the half the resolution height. Eg. for 1024x768, set it to 384.
Or for a normal camera, take the spine sprite and scale it down appropriately.
Half? i remember it should be 768 since it works for me at full height, in fact, you mentioned it before
"Eg.
In sprite collection, set target resolution height = 640, ortho size = 10
In your game window, create a camera, set to orthographic. Set Orthographic size = 10. If your game is running at 960x640 or indeed any other resolution with a 640 height (1024x640, 2046x640, ...) then your sprites will be pixel perfect when the scale on them is 1,1,1. No need to click 1:1, or indeed anything else."
This is quoted from you in my previous post about 2dtkCamera...
And in fact from the video you saw no matter what size I choose it has no effect at all. And I'm a bit confused about your explanation of "The skinned sprite created by the spine integration doesn't use the scale, just the UVs from the atlas." How does this explain the bug I'm having?
So confused :(
-
1. The skinned mesh generated by the spine integration uses 1 world unit per pixel and ignores the size set in the sprite collection. I didn't write this, nor do I have anything to do with it, so I can't really advise you on what you need to do to make it change size when you change the sprite collection settings.
2. Since the spine skinned mesh doesn't change size based on the sprite collection settings, you should use a camera in Unity that works with it instead.
3. The advice from before was for tk2d sprites, with an ortho camera. That still stands, but your request now has nothing to do with that, as the spine mesh is NOT a tk2d sprite. Its a Spine Unity mesh, that uses the tk2d atlas. Thats it.
4. So to make this pixel perfect - since you don't know how the spine stuff works, use a tk2dCamera. The spine skinned mesh will be pixel perfect in there.
Or if you don't want to use tk2dCamera, set up an ortho camera like I said before: orthographic size set to 1/2 of resolution height. This will make the ortho camera use the same scale sprites as a tk2dCamera.This advice is specific to the issue you're having here. You don't want to use the tk2dCamera, so use an ortho camera that uses the same scale instead.
-
1. The skinned mesh generated by the spine integration uses 1 world unit per pixel and ignores the size set in the sprite collection. I didn't write this, nor do I have anything to do with it, so I can't really advise you on what you need to do to make it change size when you change the sprite collection settings.
2. Since the spine skinned mesh doesn't change size based on the sprite collection settings, you should use a camera in Unity that works with it instead.
3. The advice from before was for tk2d sprites, with an ortho camera. That still stands, but your request now has nothing to do with that, as the spine mesh is NOT a tk2d sprite. Its a Spine Unity mesh, that uses the tk2d atlas. Thats it.
4. So to make this pixel perfect - since you don't know how the spine stuff works, use a tk2dCamera. The spine skinned mesh will be pixel perfect in there.
Or if you don't want to use tk2dCamera, set up an ortho camera like I said before: orthographic size set to 1/2 of resolution height. This will make the ortho camera use the same scale sprites as a tk2dCamera.This advice is specific to the issue you're having here. You don't want to use the tk2dCamera, so use an ortho camera that uses the same scale instead.
Thanks for the answer! 2dtk camera does work for me (it's having weird perspective tho, but at least i see the pixel perfect result)
As for ortho camera, you mean set the ortho size of the camera itself but not the target ortho size in sprite collection editor? I can't change the ortho size of the camera since in my game there are other sprites in the backgroun and they are working correctly, changing ortho size will break that relation. I understand you are advising regarding this specific issue, but I do need to put the skeleton in a bigger picture eventually.
Done to the last point, I just want to confirm that it's impossible to change spine skeleton size simply by changing the target height and target ortho size in the collector. Since the spine author claims that it works for him but not me, and i have tried this on 2 computers and can't get the scaling working, if it doesn't work for you either then this is probably a spine related issue and I have more proofs here.
-
Well if you can't change the camera size, and you know that the spine skinned mesh creates 1 pixel = 1 world unit, surely you can simply scale the spine object to fit whatever camera you're using.
The scale on the spine object to match an ortho camera should be (on x, y & z) :
2.0 * ortho size / native resolution height.
-
Well if you can't change the camera size, and you know that the spine skinned mesh creates 1 pixel = 1 world unit, surely you can simply scale the spine object to fit whatever camera you're using.
The scale on the spine object to match an ortho camera should be (on x, y & z) :
2.0 * ortho size / native resolution height.
I finally had some talk with the spine developer, seemed he had some problem figuring out the 2dtk atlas documentation,
Here are his post:
The code that converts a TK2D sprite collection into a Spine atlas is here:
https://github.com/EsotericSoftware/spine-runtimes/blob/master/spine-tk2d/Code/tk2dSpineAttachmentLoader.cs
I am guessing the tk2dSpriteCollectionData field "halfTargetHeight" has something to do with the target ortho size. Do you know? The docs are not very helpful:
http://www.unikronsoftware.com/2dtoolkit/doc/2.00/html/classtk2d_sprite_collection_data.html#a8c9ee0897498269327432bb5e16c2f69
Not sure why you need to scale it down so much, but instead of using the Unity transform to scale, you can scale the skeleton data asset. You can set this in the Unity inspector. If we figure out how to determine a scale from the TK2D sprite collection based on the target ortho size, then maybe we can get rid of the scale in the skeleton data inspector and set the scale appropriately:
https://github.com/EsotericSoftware/spine-runtimes/blob/master/spine-tk2d/Code/tk2dSpineSkeletonDataAsset.cs#L47
Any insight on this? I'm no developer on either so it's hard to say that I understand those code :(
-
The answer to this is in the previous post:
scale = 2.0 * ortho size / native resolution height.
So in relation to the sprite collection data, just reworking the equation, its
scale = 1.0f / (invOrthoSize * halfTargetHeight);
-
@ryf9059
Open tk2dSpineSkeletonDataAsset.cs
Delete (or comment out) line 12:
public float scale = 1;
Change line 47 from:
json.Scale = scale;
To:
json.Scale = 1.0f / (spritesData.invOrthoSize * spritesData.halfTargetHeight);
Now when you go to to the SpriteCollection Settings and changeTarget Height and/or Target Ortho Size then click commit, you will immediately see the size change!
cheers
evs
-
@Evs Thanks for posting that :)
I've been stuck catching up with such a huge backlog.