Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


SetPreBakeCollisionMesh(Mesh, bool, bool)

Enables or disables pre-baked collision data for this mesh.
Read time 1 minuteLast updated 13 days ago

Definition

  • Type: Method
  • Namespace: UnityEditor
  • Assembly: UnityEditor
public static void SetPreBakeCollisionMesh(this Mesh mesh, bool isConvex, bool preBake)

Parameters

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.

Remarks

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.