Class ARMeshManager
A manager for triangle meshes generated by an AR device. Creates, updates, and removes GameObjects in response to the environment. For each mesh, a meshPrefab is instantiated which must contain at least a MeshFilter. If the meshPrefab's GameObject also has a MeshCollider, then a physics mesh is generated asynchronously, without blocking the main thread.
Inherited Members
Namespace: UnityEngine.XR.ARFoundation
Assembly: Unity.XR.ARFoundation.dll
Syntax
[DefaultExecutionOrder(-2147483647)]
[DisallowMultipleComponent]
[AddComponentMenu("XR/AR Foundation/AR Mesh Manager")]
[Icon("Packages/com.unity.xr.arfoundation/Editor/Icons/d_ARVR@4x.png")]
public class ARMeshManager : MonoBehaviour
Remarks
Related information: AR Mesh Manager component
Fields
meshInfosChanged
Invoked whenever meshes have changed (been added, updated, or removed).
Declaration
public UnityEvent<ARMeshInfosChangedEventArgs> meshInfosChanged
Field Value
| Type | Description |
|---|---|
| UnityEvent<ARMeshInfosChangedEventArgs> |
Properties
colors
If true, requests a color value for each vertex in generated meshes.
Declaration
public bool colors { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
concurrentQueueSize
The number of meshes to process concurrently. Meshes are processed on a background thread. Higher numbers will require additional CPU time.
Declaration
public int concurrentQueueSize { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
density
The density of the generated mesh [0..1]. 1 will be densely tessellated, while 0 will have the lowest supported tessellation.
Declaration
public float density { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
meshPrefab
A Prefab to be instantiated for each generated mesh. The Prefab must have at least a
MeshFilter component on it.
If it also has a MeshCollider
component, the physics bounding volume data will be generated asynchronously. This does not block the
main thread, but might take longer to process.
Declaration
public MeshFilter meshPrefab { get; set; }
Property Value
| Type | Description |
|---|---|
| MeshFilter |
meshes
Returns a collection of MeshFilters that represents meshes generated by this component.
Declaration
public IList<MeshFilter> meshes { get; }
Property Value
| Type | Description |
|---|---|
| IList<MeshFilter> |
normals
If true, requests a normal for each vertex in generated meshes.
Declaration
public bool normals { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
submeshClassificationEnabled
Gets or sets the current enabled state of submesh classification. Note that some providers may require a restart if this value is changed in order to reflect the new setting.
Declaration
public bool submeshClassificationEnabled { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
subsystem
The XRMeshSubsystem used by this component to generate meshes.
Declaration
public XRMeshSubsystem subsystem { get; }
Property Value
| Type | Description |
|---|---|
| XRMeshSubsystem |
tangents
If true, requests a tangent for each vertex in generated meshes.
Declaration
public bool tangents { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
textureCoordinates
If true, requests a texture coordinate for each vertex in generated meshes.
Declaration
public bool textureCoordinates { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Methods
DestroyAllMeshes()
Destroys all generated meshes and ignores any pending meshes.
Declaration
public void DestroyAllMeshes()
TryGetSubmeshClassifications(TrackableId, Allocator, out uint, out NativeArray<uint>, out NativeArray<uint>)
Gets classification information for vertices or vertex sets for meshes obtained through [meshInfosChanged]. This must be enabled through [submeshClassificationEnabled].
Declaration
public bool TryGetSubmeshClassifications(TrackableId id, Allocator allocator, out uint indexVectorLength, out NativeArray<uint> vertexIndexVectors, out NativeArray<uint> classifications)
Parameters
| Type | Name | Description |
|---|---|---|
| TrackableId | id | The TrackableId of the mesh to obtain classifications for |
| Allocator | allocator | The Allocator type the [vertexIndexVectors] and [classifications] NativeArrays should be created with. |
| uint | indexVectorLength | The number of vertex indices packed in [vertexIndexVectors] that should be considered as one classified element, e.g. 1 for a single vertex, or 3 for a triangle face. |
| NativeArray<uint> | vertexIndexVectors | The packed vertex indices that are classified, collated with the applicable [classifications] |
| NativeArray<uint> | classifications | The classifications for the mesh components describing the vertex indices |
Returns
| Type | Description |
|---|---|
| bool |
Events
meshesChanged
Invoked whenever meshes have changed (been added, updated, or removed).
Declaration
[Obsolete("meshesChanged is deprecated in AR Foundation 6.4. Use meshInfosChanged instead", true)]
public event Action<ARMeshesChangedEventArgs> meshesChanged
Event Type
| Type | Description |
|---|---|
| Action<ARMeshesChangedEventArgs> |