Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


HasPreBakeCollisionMesh(Mesh, bool)

Checks whether the mesh should pre-bake collision data during a player build.
Read time 1 minuteLast updated 14 days ago

Definition

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

Parameters

mesh

The mesh to check.

isConvex

True to check for convex collision data, false to check for triangle collision data.

Returns

Type

Description

boolReturns true if the mesh should contain pre-baked collision data in a player build, false otherwise.

Remarks

When building a player, convex and/or triangle collision data can be pre-baked inside the Mesh. This allows MeshCollider referencing that Mesh to efficiently fetch that collision data at runtime.
When no collision data is pre-baked, it will be generated at runtime when the mesh is used with a MeshCollider, which can have an impact on performance.
Note that the collision data is only baked during a player build, so if the methods returns true but the mesh hasn't been built yet as part of player build, it means it doesn't contain any pre-baked collision data yet.