Class XRReferenceObjectLibrary
A container for reference objects. A reference object represents a 3D scan of a real object that can be recognized in the environment. A XRObjectTrackingSubsystem will search for objects based on the contents of a XRReferenceObjectLibrary.
Inherited Members
Namespace: UnityEngine.XR.ARSubsystems
Syntax
[CreateAssetMenu(fileName = "ReferenceObjectLibrary", menuName = "XR/Reference Object Library", order = 3)]
public class XRReferenceObjectLibrary : ScriptableObject, IEnumerable<XRReferenceObject>, IEnumerable
Properties
count
The number of reference objects in the library.
Declaration
public int count { get; }
Property Value
Type | Description |
---|---|
Int32 |
guid
A GUID
associated with this reference library.
The GUID is used to uniquely identify this library at runtime.
Declaration
public Guid guid { get; }
Property Value
Type | Description |
---|---|
Guid |
Item[Int32]
Get a reference object by index.
Declaration
public XRReferenceObject this[int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | The index in the array of reference objects. Must be greater than or equal to 0 and less than count. |
Property Value
Type | Description |
---|---|
XRReferenceObject | The XRReferenceObject at |
Methods
Add(XRReferenceObject)
Adds a new XRReferenceObject to this library.
Declaration
public void Add(XRReferenceObject referenceObject)
Parameters
Type | Name | Description |
---|---|---|
XRReferenceObject | referenceObject | The reference object to add. |
GetEnumerator()
Gets an enumerator which can be used to iterate over the reference objects in this library.
Declaration
public List<XRReferenceObject>.Enumerator GetEnumerator()
Returns
Type | Description |
---|---|
List.Enumerator<> | Returns an enumerator which can be used to iterate over the reference objects in this library. |
Examples
This examples iterates over the reference objects contained in the library.
XRReferenceObjectLibrary library = ...
foreach (var referenceObject in library)
{
Debug.LogFormat("Reference object guid: {0}", referenceObject.guid);
}
indexOf(XRReferenceObject)
Get the index of referenceObject
in the object library.
Declaration
[Obsolete("Use IndexOf instead (deprecated 2021-02-01).")]
public int indexOf(XRReferenceObject referenceObject)
Parameters
Type | Name | Description |
---|---|---|
XRReferenceObject | referenceObject | The XRReferenceObject to find. |
Returns
Type | Description |
---|---|
Int32 | The zero-based index of the |
IndexOf(XRReferenceObject)
Get the index of referenceObject
in the object library.
Declaration
public int IndexOf(XRReferenceObject referenceObject)
Parameters
Type | Name | Description |
---|---|---|
XRReferenceObject | referenceObject | The XRReferenceObject to find. |
Returns
Type | Description |
---|---|
Int32 | Returns the zero-based index of the |
Explicit Interface Implementations
IEnumerable<XRReferenceObject>.GetEnumerator()
Gets an enumerator which can be used to iterate over the reference objects in this library.
Declaration
IEnumerator<XRReferenceObject> IEnumerable<XRReferenceObject>.GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator<XRReferenceObject> | Returns an object which can be used to iterate over the reference objects in this library. |
Implements
IEnumerable.GetEnumerator()
Gets an enumerator which can be used to iterate over the reference objects in this library.
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator | Returns an object which can be used to iterate over the reference objects in this library. |