2D Toolkit Forum

2D Toolkit => Support => Topic started by: Goepfie on April 04, 2013, 01:01:09 pm

Title: Scaled TK2DSlicedSprite loses BoxCollider bounds on SpirteChange
Post by: Goepfie on April 04, 2013, 01:01:09 pm
Hey,

I am using several SlicedSprites which are dynamically instantiated and manually scaled and positioned. When I change the Sprite using SetSprite( string Name ) it loses its BoxCollider Bounds. At this point the bounds do not change, but I dont know the extents it should have. Is this a Bug or expected behaviour? Currently I circumvent the problem by caching the bounds manually.

Thanks.
Title: Re: Scaled TK2DSlicedSprite loses BoxCollider bounds on SpirteChange
Post by: unikronsoftware on April 04, 2013, 08:31:40 pm
The behaviour for this has changed in tk2d 1.92.
In 1.92, the collider setting is a property of the sliced / clipped / tiled sprite. As long as it is set to true, it should always update correctly.

What version are you on?
Title: Re: Scaled TK2DSlicedSprite loses BoxCollider bounds on SpirteChange
Post by: Goepfie on April 08, 2013, 01:48:02 pm
I am on 1.92 final + patch 1 and Unity 4.1.2. Instantiation is handled through PoolManager 4
CreateBoxCollider is true on the prefab, and the ColliderType in the collection is set to BoxTrimmed.

Currently I set the sprite and collider after instantiation through:

Code: [Select]
((tk2dSlicedSprite)(this.GetComponent<tk2dSlicedSprite>())).scale = new Vector3(xfactor, yfactor, 1);
((BoxCollider)(this.GetComponent<BoxCollider>())).size = new Vector3(width, height, 0.2f);
Title: Re: Scaled TK2DSlicedSprite loses BoxCollider bounds on SpirteChange
Post by: unikronsoftware on April 19, 2013, 12:58:35 pm
The issue with this is due to "legacy mode". This has been removed in tk2d 2.0, but for now, please set slicedsprite.legacyMode = false; after creating it.