I am re-posting this again so its clearer. The Scripts posted below use BakeCollider to update the Collider for SpriteShape Renderer. The source of these scripts are not internal and can be easily integrated into any project. Please use them as reference for BakeCollider usage.
SpriteShape Preview Package page-6#post-4479055
We understand that different games/styles can have different needs for collider generation. Based on inputs and feedback such as the ones above, we have provided some additional scripts for collider generation in the sample project. More info and simple demonstration videos as follows:
Geometry Based Collider (Collider from Render Geometry):
Generates collider data from the Renderer geometry and is more precise. This is available in from the sample project here.
https://github.com/Unity-Technologies/2d-spriteshape-samples/blob/master/Assets/Unity Technologies/2D SpriteShape/Extras/Scripts/GeometryCollider.cs
Once you import this script to your project you can select Menu → SpriteShape → Generate Geometry Collider to generate spriteshape collider data for EdgeCollider2D or PolygonCollider2D if present in the select gameObject.
- Generates collider data from the render data and provides best fit collider.
- Collider is generated in main-thread and could be slower than the default generator.
- Collider Quality levels or Optimize collider does not apply.
Legacy Collider (Collider generator that shipped with 2018.* versions):
Collider generator that ships with 2018.* versions of SpriteShape. Might be useful for developers who need backward compatibility.
This is available at :
https://github.com/Unity-Technologies/2d-spriteshape-samples/blob/master/Assets/Unity Technologies/2D SpriteShape/Extras/Scripts/LegacyCollider.cs
Once you import this script to your project you can select Menu → SpriteShape → Generate Legacy Collider to generate spriteshape collider data for EdgeCollider2D or PolygonCollider2D if present in the select gameObject.
- Generates collider data only based on Spline data and does not take into account different height or sprite size in the control points.
- Collider Quality levels or Optimize collider does not apply.