Class XRReferenceImageLibrary
A reference image library is a collection of images to search for in the physical environment when image tracking is enabled.
Implements
Inherited Members
Namespace: UnityEngine.XR.ARSubsystems
Assembly: Unity.XR.ARSubsystems.dll
Syntax
[CreateAssetMenu(fileName = "ReferenceImageLibrary", menuName = "XR/Reference Image Library", order = 1001)]
public class XRReferenceImageLibrary : ScriptableObject, IReferenceImageLibrary, ISerializationCallbackReceiver, IEnumerable<XRReferenceImage>, IEnumerable
Remarks
Image libraries are immutable at runtime. To create and manipulate an image library via Editor scripts, use the extension methods in XRReferenceImageLibraryExtensions. To work with image libraries at runtime, create a RuntimeReferenceImageLibrary. If you need to mutate the library at runtime, see MutableRuntimeReferenceImageLibrary.
Properties
this[int]
Get an image by index.
Declaration
public XRReferenceImage this[int index] { get; }
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | The index of the image in the library. Must be between 0 and count - 1. |
Property Value
| Type | Description |
|---|---|
| XRReferenceImage | The XRReferenceImage at |
Exceptions
| Type | Condition |
|---|---|
| IndexOutOfRangeException | Thrown if |
count
The number of images in the library.
Declaration
public int count { get; }
Property Value
| Type | Description |
|---|---|
| int |
dataStore
(Read Only) Binary data associated with a string key.
Declaration
public IReadOnlyDictionary<string, byte[]> dataStore { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyDictionary<string, byte[]> |
Remarks
This is used by providers to associate provider-specific data with the library. During Player Build (in an IPreprocessBuildWithReport.OnPreprocessBuild callback), the data store is first cleared. Each enabled provider then has an opportunity to add one or more entries for itself.
Providers can use this to store a serialized version of the image library specific to that provider. Set data with XRReferenceLibraryExtensions.SetDataForKey.
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 |
movingImageType
Indicates whether the images in this library are expected to move in the real world.
Declaration
public MovingImageType movingImageType { get; }
Property Value
| Type | Description |
|---|---|
| MovingImageType |
Remarks
This value is overridden by the moving image setting of an individual image in the library if that image's setting is anything other than Unspecified. Defaults to Unspecified.
Methods
Create(ReadOnlyStructSpan<XRReferenceImage>, MovingImageType)
Creates a new XRReferenceImageLibrary instance with the provided data.
Declaration
public static XRReferenceImageLibrary Create(ReadOnlyStructSpan<XRReferenceImage> images, MovingImageType movingImageType = MovingImageType.Unspecified)
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlyStructSpan<XRReferenceImage> | images | The reference images to include in the library. |
| MovingImageType | movingImageType | The moving image type for the library, which serves as the default for any contained XRReferenceImage with a moving image type of Unspecified. |
Returns
| Type | Description |
|---|---|
| XRReferenceImageLibrary | A new XRReferenceImageLibrary instance. |
GetEnumerator()
Gets an enumerator which can be used to iterate over the reference images in this library.
Declaration
public List<XRReferenceImage>.Enumerator GetEnumerator()
Returns
| Type | Description |
|---|---|
| List<XRReferenceImage>.Enumerator | Returns an enumerator which can be used to iterate over the reference images in the library. |
Examples
This example iterates over the reference images contained in the library.
XRReferenceImageLibrary imageLibrary = ...
foreach (var referenceImage in imageLibrary)
{
Debug.LogFormat("Image guid: {0}", referenceImage.guid);
}
indexOf(XRReferenceImage)
Get the index of referenceImage in the image library.
Declaration
public int indexOf(XRReferenceImage referenceImage)
Parameters
| Type | Name | Description |
|---|---|---|
| XRReferenceImage | referenceImage | The XRReferenceImage to find. |
Returns
| Type | Description |
|---|---|
| int | The zero-based index of the |