2D Sprite Shape 4.1.1 for Unity 2020.1

2D Sprite Shape 4.1.1 is now available for the latest beta of Unity 2020.1.
This versions includes Stretched Corners and Sprite Shape mesh baking functionality.

Stretched Corners
We’ve added Stretched corners as a new option for Corner’s in the Sprite Shape Controller.


This feature allows the Sprite Shape to form corners by stretching Sprites between adjacent edges between the corner point and its neighbours. To enable this option, select the Stretched option from the Corner dropdown menu, and ensure the following criteria are met:

  • Both the selected and adjacent points have the same Height.
  • Sprites rendered at the Corner point and its neighbouring points must have the same Sprite pivot position.

Please note that scripting support for this new Corner mode will be available in a later release.

SpriteShape mesh baking
SpriteShape mesh baking allows storage of mesh data at editor time and the ability to reload it at runtime to avoid unnecessary runtime mesh generation.

This is helpful in cases where:

  • You have a static SpriteShape that never gets modified in runtime.

  • You have a SpriteShape used with prefabs.

  • You want to avoid SpriteShape generation at runtime to save CPU cycles

Some things to consider:

  • Since data is stored in a SpriteShape Component, scene size can increase if it contains a lot of SpriteShape objects with massive geometry.
  • SpriteShapes baked in such a way cannot be dynamically modified during Runtime.
1 Like

Nice.
Although 4.1.1 doesn’t show up in 2019.3. I can still change the manifest manually and it does seem to work in 2019.3.

Any reason why 4.1.1 is not available officially for 2019.3?
Is this a bad idea enabling 4.1.1 in 2019.3?

1 Like

Stretched Corners is only available in 4.1.1 and above (4.* versions are designed for 2020.1). However we have backported BakeMesh functionality to 3.* versions and it should be available soon (for 2019.3).

Please note 4.* versions might work on 2019.3 but its not recommended to use them as there may be changes in the API or functionality.

Can you explain more about the mesh baking? How do we use this?

Hey, the video about this feature on this page here is broken:
https://unity.com/releases/2020-1/artist-tools

Is there any way to do this with curved lines too? I just played a little with Sprite shape, but when using Continous lines, I dont seem to get the transitions between different sprites on different angles. Am I missing something?

Cause it seems like a great way to build a 2D lake in a top down game line ours, but i want the edge facing side and down to have a different sprite and would love for it to transition nicely from the top sprite.

Thanks for your awesome work!

Is there some example how to bake Spriteshape mesh? I cant figure it out. There is a
public JobHandle BakeMesh() method on spriteShapeController, but i dont see how i get refference to the generated mesh @rustum

Please take a look at this video for more info on Baking SpriteShape Geometry :

https://www.youtube.com/watch?v=vIM97rD3O9E

Thank you for reply, I saw this video, but still It dont answer the question. How I can get the actual refference of the generated mesh. What I see is that the mesh is somehow stored in SpriteShape controller, but I cant get the actual mesh from it.There is not Spriteshape.mesh variable. Can you please add this featurem without is is somehow useless… Thank you

@larex39 please take a look at :
com.unity.2d.spriteshape\Runtime\SpriteShapeGeometryCache.cs
which is part of the SpriteShape Package. This is where the mesh data (position/uv/traingles etc…) is stored when SpriteShape Cache Geometry is enabled.

I checked it, but the class is internal so I cant access it from any script. But even if it would be accesible, I see positions, uvs but I cant see triangles, so I dont think I can recreate actual mesh from it… So how we can use it?

Please use SpriteShapeGeometryCache.cs mentioned above as reference to implementing custom mesh load/store.

m_IndexArray stores the triangle data. Thanks.

@Venkify Thank you for your help, I will try it.

@Venkify I tryed your suggestion, but still I cant get the whole mesh. I only got One segment of spriteshape recreated. My problem is in the code you seggested inside SpriteShapeGeometryCache.cs. I dont know how to get this variable
“NativeArray<UnityEngine.U2D.SpriteShapeSegment> m_GeomArrayCache”.

This one holds the segment count of the spriteshape and also counts of indexes. Can you please give me code snipped how to get this information. Thank you very much.

@Venkify I found the solution I can get it with SpriteShapeRenderer.GetSegments(int dataSize).

is there some way to get the dataSize number, so i dont neet to put some quessing number?

Thanks a lot