Sprite.Create not creating Physics shape after building the game.

I’m using the following line of code to Create a sprite from a texture.

Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), pivot, 100f, 1, meshType, new Vector4(), true);

I’ve set the last parameter ‘generateFallbackPhysicsShape’ to true to ensure a Physics shape is generated. This works fine when I enter playmode from the Editor. However, after I build the game, the physics shape won’t be generated at all.

Does anyone have an idea why this doesn’t work after building the game, and perhaps a way to work around it?

I figured out this failed because the texture wasn’t readable at runtime. After setting Read/Write enabled in the import settings of the texture, it worked as expected.

1 Like