DestructibleMeshComponent Class
Extends MonoBehaviour
The DestructibleMeshComponent handles the segmentation and manipulation of a mesh to create a segmented version of the original.
Used mainly to build destructible environments in conjunction with a global mesh. For mor details on its usage see DestructibleGlobalMeshSpawner It uses asynchronous tasks to perform the computations for mesh segmentation based on specified parameters and reserved areas.
Event triggered when a destructible mesh is successfully created.
Function delegate that processes the segmentation result.
It can be used to modify the segmentation results before they are instantiated.
Material GlobalMeshMaterial[Get]
Gets or sets the material used for the mesh.
This material is applied to the mesh segments that are created during the segmentation process.
Gets or sets the reserved space at the top of the mesh.
This space is not included in the destructible area, allowing for controlled segmentation.
float ReservedBottom[Get]
Gets or sets the reserved space at the bottom of the mesh.
TThis space is not included in the destructible area, allowing for controlled segmentation.
GameObject ReservedSegment[Get]
Gets the game object associated to the reserved segment defined as the portion of the mesh that should be indestructible.
Can be null if no segment has been reserved.
unsafe void SegmentMesh ( Vector3[] meshPositions,
uint[] meshIndices,
Vector3[] segmentationPoints )
Initiates the mesh segmentation process asynchronously based on the provided mesh positions, indices, and segmentation points.
It uses native functions to perform the segmentation and updates the mesh accordingly.
ParametersmeshPositionsArray of mesh vertex positions.
meshIndicesArray of mesh indices.
segmentationPointsArray of points used for segmenting the mesh.
int GetDestructibleMeshSegmentsCount ( )
Returns the count of destructible mesh segments currently managed by this component.
ReturnsThe number of child GameObjects representing mesh segments.
void GetDestructibleMeshSegments< T > ( T segments )
Populates a provided container with GameObjects representing the destructible mesh segments.
The container will be cleared before being populated.
OthersTThe type of the list to populate, must implement IList<GameObject>.
ParameterssegmentsThe list to populate with mesh segment GameObjects.
void GetDestructibleMeshSegments ( GameObject[] segments )
Populates an array with GameObjects representing the destructible mesh segments.
The array should be provided with enough space to hold all segments. see GetDestructibleMeshSegmentsCount.
ParameterssegmentsThe array to populate with mesh segment GameObjects.
void DestroySegment ( GameObject segment )
Cleans up created mesh segments when the component is destroyed or reset.
ParameterssegmentThe game object associated to the segment to be destroyed.