Struct XRReferenceImage
Represents an entry in an XRReferenceImageLibrary.
Implements
Inherited Members
Namespace: UnityEngine.XR.ARSubsystems
Assembly: Unity.XR.ARSubsystems.dll
Syntax
[Serializable]
public struct XRReferenceImage : IEquatable<XRReferenceImage>
Remarks
A reference image is an image to look for in the physical environment.
The XRReferenceImage does not directly reference a Texture2D
or other image data; it only stores the GUID of the Texture2D as it
appears in the AssetDatabase. At build time, platform-specific build steps
can use the GUIDs to look up the source textures and generate an appropriate
image database. At runtime, detected images can be matched up with the source
XRReferenceImage.
Constructors
XRReferenceImage(SerializableGuid, SerializableGuid, Vector2?, string, Texture2D)
Constructs a XRReferenceImage.
Declaration
public XRReferenceImage(SerializableGuid guid, SerializableGuid textureGuid, Vector2? size, string name, Texture2D texture)
Parameters
| Type | Name | Description |
|---|---|---|
| SerializableGuid | guid | The Guid associated with this image. |
| SerializableGuid | textureGuid | The Guid of the source texture as it appeared in the AssetDatabase in the Editor. |
| Vector2? | size | Optional. The size of the image, in meters. This can improve image detection, and might be required by some platforms. |
| string | name | A name associated with this reference image. |
| Texture2D | texture | The source texture which this reference image represents.
This can be |
Properties
guid
The Guid associated with this image.
Declaration
public Guid guid { get; }
Property Value
| Type | Description |
|---|---|
| Guid |
height
The height of the image, in meters.
Declaration
public float height { get; }
Property Value
| Type | Description |
|---|---|
| float |
name
A name associated with this reference image.
Declaration
public string name { get; }
Property Value
| Type | Description |
|---|---|
| string |
size
The size of the image, in meters. This can improve image detection, and might be required by some platforms.
Declaration
public Vector2 size { get; }
Property Value
| Type | Description |
|---|---|
| Vector2 |
specifySize
Must be set to true for size to be used.
Declaration
public bool specifySize { get; }
Property Value
| Type | Description |
|---|---|
| bool |
texture
The source texture which this reference image represents.
This may be null to avoid including the texture in
the Player build if you don't want that. See
UnityEditor.XR.ARSubsystems.XRReferenceImageLibraryExtensions.SetTexture
for more details.
Declaration
public Texture2D texture { get; }
Property Value
| Type | Description |
|---|---|
| Texture2D |
textureGuid
The Guid of the source texture as it appears in the AssetDatabase in the Editor.
Declaration
public Guid textureGuid { get; }
Property Value
| Type | Description |
|---|---|
| Guid |
width
The width of the image, in meters.
Declaration
public float width { get; }
Property Value
| Type | Description |
|---|---|
| float |
Methods
Equals(object)
Tests for equality.
Declaration
public override bool Equals(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| object | obj | The |
Returns
| Type | Description |
|---|---|
| bool |
|
Overrides
Equals(XRReferenceImage)
Tests for equality.
Declaration
public bool Equals(XRReferenceImage other)
Parameters
| Type | Name | Description |
|---|---|---|
| XRReferenceImage | other | The other XRReferenceImage to compare against. |
Returns
| Type | Description |
|---|---|
| bool |
|
GetHashCode()
Generates a hash suitable for use with containers like HashSet and Dictionary.
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| int | A hash code generated from this object's guid. |
Overrides
ToString()
Provides a string representation suitable for debug logging.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string | A string representation of the reference image. |
Overrides
Operators
operator ==(XRReferenceImage, XRReferenceImage)
Tests for equality. Same as Equals(XRReferenceImage).
Declaration
public static bool operator ==(XRReferenceImage lhs, XRReferenceImage rhs)
Parameters
| Type | Name | Description |
|---|---|---|
| XRReferenceImage | lhs | The left-hand side of the comparison. |
| XRReferenceImage | rhs | The right-hand side of the comparison. |
Returns
| Type | Description |
|---|---|
| bool |
|
operator !=(XRReferenceImage, XRReferenceImage)
Tests for inequality. Same as !Equals(XRReferenceImage).
Declaration
public static bool operator !=(XRReferenceImage lhs, XRReferenceImage rhs)
Parameters
| Type | Name | Description |
|---|---|---|
| XRReferenceImage | lhs | The left-hand side of the comparison. |
| XRReferenceImage | rhs | The right-hand side of the comparison. |
Returns
| Type | Description |
|---|---|
| bool |
|