Home Game Development unity – Copy sprite with completely different geometry in Runtime

unity – Copy sprite with completely different geometry in Runtime

0
unity – Copy sprite with completely different geometry in Runtime

[ad_1]

I’ve received some isometric 32×16 tiles

enter image description here

Which i divide into 4 items, as an example the highest left 16×8 piece:

enter image description here

What im attempting to realize, is to from this nook which is a Sprite object, generate a triangle sprite solely containing the sprite itself with out what’s within the border:

enter image description here

In my present try im attempting to repeat the sprite at runtime and redefine the copy geometry:

            var tileSetup = tilesetSetup.TileSprite;
            var copy = Sprite.Create(
                tileSetup.TopLeft.texture,
                tileSetup.TopLeft.textureRect,
                tileSetup.TopLeft.pivot,
                tileSetup.TopLeft.pixelsPerUnit,
                0,
                SpriteMeshType.Tight
            );
            copy.OverrideGeometry(new Vector2[]
            {
                new Vector2(0,16), new Vector2(16,0),  new Vector2(16,8),
            }, new ushort[] { 0, 1, 2 });
    
            tileSetup.TopLeftNoCorner = copy;

But it all the time renders a clean picture.

Does anybody have any concepts how to do that ?

Thanks !

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here