Change Profile of SpriteShapeController by code

I have made a SpriteShapeController and attached a Sprite Shape profile to it, now I want to change this Profile at runtime.

I am trying to access the Profile like this on the SpriteShapeController Gameobject
GetComponent()…
I don’t see any option to choose Profile here so that I can chase it by code. See the screenshot below in terms of where I want it to change dynamically.

Looking forward to some guidance and help.

You can set the public property named .spriteShape. It’s a bit confusing that the actual type name of what’s called SpriteShapeProfile in the UI is just “SpriteShape”.

After you set it, you want to call RefreshSpriteShape() on the Controller, which causes it to realize that it has to rebuild things.

Thank you @Baste That was very helpful. It works perfectly fine. Thanks again!

How do you even populate the sprite shape profile in the editor? It says “None” and no matter what I drag in it it won’t take it

You cannot use normal sprites for the sprite shape profile. You have to create a sprite shape profile by going to Assets and right clicking; navigate the menu: Create>2D>SpriteShapeProfile