Hello Guest

Author Topic: URGENT: with spine with 2dtk in unity problem.  (Read 19279 times)

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: URGENT: with spine with 2dtk in unity problem.
« Reply #15 on: May 27, 2013, 04:35:39 pm »
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.


ryf9059

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 41
    • View Profile
Re: URGENT: with spine with 2dtk in unity problem.
« Reply #16 on: June 03, 2013, 02:43:35 pm »
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 :(

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: URGENT: with spine with 2dtk in unity problem.
« Reply #17 on: June 03, 2013, 02:54:37 pm »
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);


evs

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: URGENT: with spine with 2dtk in unity problem.
« Reply #18 on: June 03, 2013, 06:43:53 pm »
@ryf9059
 
Open tk2dSpineSkeletonDataAsset.cs

Delete (or comment out) line 12:

Code: [Select]
public float scale = 1;
Change line 47 from:

Code: [Select]
json.Scale = scale;
To:

Code: [Select]
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

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: URGENT: with spine with 2dtk in unity problem.
« Reply #19 on: June 03, 2013, 07:06:06 pm »
@Evs Thanks for posting that :)
I've been stuck catching up with such a huge backlog.