Version: Unity 6.6 Alpha (6000.6)
LanguageEnglish
  • C#

PhysicsEditorMeshExtensions.SetPreBakeCollisionMesh

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public static void SetPreBakeCollisionMesh(Mesh mesh, bool isConvex, bool preBake);

Parameters

Parameter Description
mesh The mesh to configure.
isConvex True to configure convex collision data, false to configure triangle collision data.
preBake True to enable pre-baking of the specified collision data, false to disable it.

Description

Enables or disables pre-baked collision data for this mesh.

This method allows you to control whether convex or triangle collision data should be pre-baked into this mesh during a player build. Pre-baking collision data improves runtime performance when the mesh is used with a MeshCollider component by avoiding the need to generate collision representations dynamically.

This method is typically used in editor scripts to configure collision data for mesh assets. After calling this method, you should save the asset using AssetDatabase.SaveAssetIfDirty, so that collision data can be baked during a player build.

To configure collision data during mesh import from a ModelImporter, use ModelImporter.SetPreBakeCollisionMesh instead.

Additional resources: HasPreBakeCollisionMesh, ModelImporter.SetPreBakeCollisionMesh, MeshCollider.