Class XRReferenceImageLibraryExtensions
Extension methods for the XRReferenceImageLibrary.
Inherited Members
Namespace: UnityEditor.XR.ARSubsystems
Syntax
public static class XRReferenceImageLibraryExtensions
Remarks
At runtime, XRReferenceImageLibrarys are immutable. These Editor-only extension methods let you build and manipulate image libraries in Editor scripts.
Methods
Add(XRReferenceImageLibrary)
Creates an empty XRReferenceImage
and adds it to the library. The new
reference image is inserted at the end of the list of reference images.
Declaration
public static void Add(this XRReferenceImageLibrary library)
Parameters
Type | Name | Description |
---|---|---|
XRReferenceImageLibrary | library | The XRReferenceImageLibrary being extended. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
ClearDataStore(XRReferenceImageLibrary)
Clears the binary data store.
Declaration
public static void ClearDataStore(this XRReferenceImageLibrary library)
Parameters
Type | Name | Description |
---|---|---|
XRReferenceImageLibrary | library | The XRReferenceImageLibrary being extended. |
Remarks
Provider-specific binary data can be associated with each XRReferenceImageLibrary (see SetDataForKey(XRReferenceImageLibrary, String, Byte[])). This is used to store arbitrarily large blocks of binary data required at runtime -- usually some form of processed image data. This data is regenerated during Player Build, and may be safely discarded otherwise. Use this method to clear the data store to avoid large files in your project.
RemoveAt(XRReferenceImageLibrary, Int32)
Removes the XRReferenceImage at index
.
Declaration
public static void RemoveAt(this XRReferenceImageLibrary library, int index)
Parameters
Type | Name | Description |
---|---|---|
XRReferenceImageLibrary | library | The XRReferenceImageLibrary being extended. |
Int32 | index | The index in the list of images to remove. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
IndexOutOfRangeException | Thrown if |
SetDataForKey(XRReferenceImageLibrary, String, Byte[])
Associate binary data with a string key.
Declaration
public static void SetDataForKey(this XRReferenceImageLibrary library, string key, byte[] data)
Parameters
Type | Name | Description |
---|---|---|
XRReferenceImageLibrary | library | The XRReferenceImageLibrary being extended. |
String | key | The key which can be used to later retrieve |
Byte[] | data | The data to associate with |
Remarks
Providers use this 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. Retrieve data with dataStore.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
SetName(XRReferenceImageLibrary, Int32, String)
Sets the XRReferenceImage.name
value on the XRReferenceImage
at index
.
This value is read-only in the Player; it can only be modified in the Editor.
Declaration
public static void SetName(this XRReferenceImageLibrary library, int index, string name)
Parameters
Type | Name | Description |
---|---|---|
XRReferenceImageLibrary | library | The |
Int32 | index | The index of the reference image within the library to modify. |
String | name |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
IndexOutOfRangeException | Thrown if |
SetSize(XRReferenceImageLibrary, Int32, Vector2)
Sets the XRReferenceImage.size
value on the XRReferenceImage
at index
.
This value is read-only in the Player; it can only be modified in the Editor.
Declaration
public static void SetSize(this XRReferenceImageLibrary library, int index, Vector2 size)
Parameters
Type | Name | Description |
---|---|---|
XRReferenceImageLibrary | library | The |
Int32 | index | The index of the reference image within the library to modify. |
UnityEngine.Vector2 | size |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
IndexOutOfRangeException | Thrown if |
SetSpecifySize(XRReferenceImageLibrary, Int32, Boolean)
Sets the XRReferenceImage.specifySize
value on the XRReferenceImage
at index
.
This value is read-only in the Player; it can only be modified in the Editor.
Declaration
public static void SetSpecifySize(this XRReferenceImageLibrary library, int index, bool specifySize)
Parameters
Type | Name | Description |
---|---|---|
XRReferenceImageLibrary | library | The |
Int32 | index | The index of the reference image within the library to modify. |
Boolean | specifySize | Whether |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
IndexOutOfRangeException | Thrown if |
SetTexture(XRReferenceImageLibrary, Int32, Texture2D, Boolean)
Set the texture on the reference image.
Declaration
public static void SetTexture(this XRReferenceImageLibrary library, int index, Texture2D texture, bool keepTexture)
Parameters
Type | Name | Description |
---|---|---|
XRReferenceImageLibrary | library | The XRReferenceImageLibrary being extended. |
Int32 | index | The reference image index to modify. |
UnityEngine.Texture2D | texture | The texture to set. |
Boolean | keepTexture | Whether to store a strong reference to the texture. If |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
IndexOutOfRangeException | Thrown if |