Version: 2023.2

XRMeshSubsystem.GenerateMeshAsync

切换到手册
public void GenerateMeshAsync (XR.MeshId meshId, Mesh mesh, MeshCollider meshCollider, XR.MeshVertexAttributes attributes, Action<MeshGenerationResult> onMeshGenerationComplete);

参数

meshId 要生成的网格的 MeshId
mesh 要将结果写入的 Mesh
meshCollider (可选)要填充物理数据的 MeshCollider。此参数可为 null。
attributes 希望使用的顶点属性。
onMeshGenerationComplete 生成完成时调用的委托。

描述

请求生成具有 MeshId meshId 的网格。生成完成时,Unity 会调用 /onMeshGenerationComplete/。

Use this method to request that a mesh is asynchronously generated. "Generation" includes extracting the mesh data from the subsystem's mesh provider (e.g., an AR device) and baking the MeshCollider (if meshCollider is not null).

This happens in a background thread. For large meshes, this can take several frames to complete. onMeshGenerationComplete is invoked when the generation completes.

The mesh vertices are provided in session space.

Additional resources: XRMeshSubsystem.TryGetMeshInfos


public void GenerateMeshAsync (XR.MeshId meshId, Mesh mesh, MeshCollider meshCollider, XR.MeshVertexAttributes attributes, Action<MeshGenerationResult> onMeshGenerationComplete, XR.MeshGenerationOptions options);

参数

meshId 要生成的网格的 MeshId
mesh 要将结果写入的 Mesh
meshCollider (可选)要填充物理数据的 MeshCollider。此参数可为 null。
attributes 希望使用的顶点属性。
onMeshGenerationComplete 生成完成时调用的委托。
options The mesh generation options.

描述

请求生成具有 MeshId meshId 的网格。生成完成时,Unity 会调用 /onMeshGenerationComplete/。

This variant allows you to specify additional mesh generation options.

Note: If the MeshGenerationOptions.ConsumeTransform flag is set in the options argument, the resulting mesh will be relative to the transform provided by the MeshGenerationResult. If this flag is not set, the vertices are transformed into session space and the MeshGenerationResult will contain an identity transform.

Additional resources: XRMeshSubsystem.TryGetMeshInfos