docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class XRReferenceImageLibrary

    A reference image library is a collection of images to search for in the physical environment when image tracking is enabled.

    Inheritance
    object
    Object
    ScriptableObject
    XRReferenceImageLibrary
    Implements
    IReferenceImageLibrary
    ISerializationCallbackReceiver
    IEnumerable<XRReferenceImage>
    IEnumerable
    Inherited Members
    ScriptableObject.SetDirty()
    ScriptableObject.CreateInstance(string)
    ScriptableObject.CreateInstance(Type)
    ScriptableObject.CreateInstance<T>()
    Object.GetInstanceID()
    Object.GetHashCode()
    Object.Equals(object)
    Object.Instantiate(Object, Vector3, Quaternion)
    Object.Instantiate(Object, Vector3, Quaternion, Transform)
    Object.Instantiate(Object)
    Object.Instantiate(Object, Transform)
    Object.Instantiate(Object, Transform, bool)
    Object.Instantiate<T>(T)
    Object.Instantiate<T>(T, Vector3, Quaternion)
    Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
    Object.Instantiate<T>(T, Transform)
    Object.Instantiate<T>(T, Transform, bool)
    Object.Destroy(Object, float)
    Object.Destroy(Object)
    Object.DestroyImmediate(Object, bool)
    Object.DestroyImmediate(Object)
    Object.FindObjectsOfType(Type)
    Object.FindObjectsOfType(Type, bool)
    Object.DontDestroyOnLoad(Object)
    Object.DestroyObject(Object, float)
    Object.DestroyObject(Object)
    Object.FindSceneObjectsOfType(Type)
    Object.FindObjectsOfTypeIncludingAssets(Type)
    Object.FindObjectsOfType<T>()
    Object.FindObjectsOfType<T>(bool)
    Object.FindObjectOfType<T>()
    Object.FindObjectOfType<T>(bool)
    Object.FindObjectsOfTypeAll(Type)
    Object.FindObjectOfType(Type)
    Object.FindObjectOfType(Type, bool)
    Object.ToString()
    Object.name
    Object.hideFlags
    object.Equals(object, object)
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    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, see the extension methods in UnityEditor.XR.ARSubsystems.XRReferenceImageLibraryExtensions. 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 index.

    Exceptions
    Type Condition
    IndexOutOfRangeException

    Thrown if index is not between 0 and count - 1.

    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 UnityEditor.XR.ARSubsystems.XRReferenceImageLibraryExtensions.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

    Methods

    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 examples 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 referenceImage, or -1 if not found.

    Implements

    IReferenceImageLibrary
    UnityEngine.ISerializationCallbackReceiver
    IEnumerable<T>
    IEnumerable

    Did you find this page useful? Please give it a rating:

    Thanks for rating this page!

    Report a problem on this page

    What kind of problem would you like to report?

    • This page needs code samples
    • Code samples do not work
    • Information is missing
    • Information is incorrect
    • Information is unclear or confusing
    • There is a spelling/grammar error on this page
    • Something else

    Thanks for letting us know! This page has been marked for review based on your feedback.

    If you have time, you can provide more information to help us fix the problem faster.

    Provide more information

    You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:

    You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:

    You've told us there is information missing from this page. Please tell us more about what's missing:

    You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:

    You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:

    You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:

    You've told us this page has a problem. Please tell us more about what's wrong:

    Thank you for helping to make the Unity documentation better!

    Your feedback has been submitted as a ticket for our documentation team to review.

    We are not able to reply to every ticket submitted.

    In This Article
    • Properties
      • this[int]
      • count
      • dataStore
      • guid
    • Methods
      • GetEnumerator()
      • indexOf(XRReferenceImage)
    • Implements
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)