Sunday, August 21, 2022
HomeGame Developmentunity - Copy sprite with completely different geometry in Runtime

unity – Copy sprite with completely different geometry in Runtime


I’ve received some isometric 32×16 tiles

enter image description here

…which I divide into 4 items, for example the highest left 16×8 piece:

enter image description here

What I am attempting to realize, is from this nook which is a Sprite object, to generate a triangle sprite containing solely the portion of the sprite inside the diamond tile itself – with out what’s within the border:

enter image description here

In my present try I am 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;

However it at all times renders a clean picture.

Does anybody have any concepts how to do that?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments