Struct XRReferenceImage
Represents an entry in an XRReferenceImageLibrary.
Inherited Members
Namespace: UnityEngine.XR.ARSubsystems
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, Nullable<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. |
Nullable<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 readonly Guid guid { get; }
Property Value
Type | Description |
---|---|
Guid |
height
The height of the image, in meters.
Declaration
public readonly float height { get; }
Property Value
Type | Description |
---|---|
Single |
name
A name associated with this reference image.
Declaration
public readonly 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 readonly Vector2 size { get; }
Property Value
Type | Description |
---|---|
Vector2 |
specifySize
Must be set to true for size to be used.
Declaration
public readonly bool specifySize { get; }
Property Value
Type | Description |
---|---|
Boolean |
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 readonly 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 readonly Guid textureGuid { get; }
Property Value
Type | Description |
---|---|
Guid |
width
The width of the image, in meters.
Declaration
public readonly float width { get; }
Property Value
Type | Description |
---|---|
Single |
Methods
Equals(Object)
Tests for equality.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
Object | obj | The |
Returns
Type | Description |
---|---|
Boolean |
|
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 |
---|---|
Boolean |
|
Implements
GetHashCode()
Generates a hash suitable for use with containers like HashSet
and Dictionary
.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 | 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
Equality(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 |
---|---|
Boolean |
|
Inequality(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 |
---|---|
Boolean |
|