docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class ColocationDiscoveryFeature

    Use this OpenXR feature to enable colocation discovery on Meta Quest devices.

    Inheritance
    object
    Object
    ScriptableObject
    OpenXRFeature
    MetaOpenXRFeature
    ColocationDiscoveryFeature
    Inherited Members
    MetaOpenXRFeature.OnEnabledChange()
    OpenXRFeature.HookGetInstanceProcAddr(IntPtr)
    OpenXRFeature.OnSubsystemCreate()
    OpenXRFeature.OnSubsystemStart()
    OpenXRFeature.OnSubsystemStop()
    OpenXRFeature.OnSubsystemDestroy()
    OpenXRFeature.OnSystemChange(ulong)
    OpenXRFeature.OnSessionCreate(ulong)
    OpenXRFeature.OnAppSpaceChange(ulong)
    OpenXRFeature.OnSessionStateChange(int, int)
    OpenXRFeature.OnSessionBegin(ulong)
    OpenXRFeature.OnSessionEnd(ulong)
    OpenXRFeature.OnSessionExiting(ulong)
    OpenXRFeature.OnSessionDestroy(ulong)
    OpenXRFeature.OnSessionLossPending(ulong)
    OpenXRFeature.OnInstanceLossPending(ulong)
    OpenXRFeature.OnFormFactorChange(int)
    OpenXRFeature.OnViewConfigurationTypeChange(int)
    OpenXRFeature.OnEnvironmentBlendModeChange(XrEnvironmentBlendMode)
    OpenXRFeature.PathToString(ulong)
    OpenXRFeature.StringToPath(string)
    OpenXRFeature.GetCurrentInteractionProfile(ulong)
    OpenXRFeature.GetCurrentInteractionProfile(string)
    OpenXRFeature.GetCurrentAppSpace()
    OpenXRFeature.GetViewConfigurationTypeForRenderPass(int)
    OpenXRFeature.SetEnvironmentBlendMode(XrEnvironmentBlendMode)
    OpenXRFeature.GetEnvironmentBlendMode()
    OpenXRFeature.GetValidationChecks(List<OpenXRFeature.ValidationRule>, BuildTargetGroup)
    OpenXRFeature.CreateSubsystem<TDescriptor, TSubsystem>(List<TDescriptor>, string)
    OpenXRFeature.StartSubsystem<T>()
    OpenXRFeature.StopSubsystem<T>()
    OpenXRFeature.DestroySubsystem<T>()
    OpenXRFeature.OnEnable()
    OpenXRFeature.OnDisable()
    OpenXRFeature.Awake()
    OpenXRFeature.GetAction(InputAction)
    OpenXRFeature.GetAction(InputDevice, InputFeatureUsage)
    OpenXRFeature.GetAction(InputDevice, string)
    OpenXRFeature.RegisterStatsDescriptor(string, OpenXRFeature.StatFlags)
    OpenXRFeature.SetStatAsFloat(ulong, float)
    OpenXRFeature.SetStatAsUInt(ulong, uint)
    OpenXRFeature.enabled
    OpenXRFeature.xrGetInstanceProcAddr
    ScriptableObject.SetDirty()
    ScriptableObject.CreateInstance(string)
    ScriptableObject.CreateInstance(Type)
    ScriptableObject.CreateInstance<T>()
    Object.GetInstanceID()
    Object.GetHashCode()
    Object.Equals(object)
    Object.InstantiateAsync<T>(T)
    Object.InstantiateAsync<T>(T, Transform)
    Object.InstantiateAsync<T>(T, Vector3, Quaternion)
    Object.InstantiateAsync<T>(T, Transform, Vector3, Quaternion)
    Object.InstantiateAsync<T>(T, int)
    Object.InstantiateAsync<T>(T, int, Transform)
    Object.InstantiateAsync<T>(T, int, Vector3, Quaternion)
    Object.InstantiateAsync<T>(T, int, ReadOnlySpan<Vector3>, ReadOnlySpan<Quaternion>)
    Object.InstantiateAsync<T>(T, int, Transform, Vector3, Quaternion)
    Object.InstantiateAsync<T>(T, int, Transform, Vector3, Quaternion, CancellationToken)
    Object.InstantiateAsync<T>(T, int, Transform, ReadOnlySpan<Vector3>, ReadOnlySpan<Quaternion>)
    Object.InstantiateAsync<T>(T, int, Transform, ReadOnlySpan<Vector3>, ReadOnlySpan<Quaternion>, CancellationToken)
    Object.InstantiateAsync<T>(T, InstantiateParameters, CancellationToken)
    Object.InstantiateAsync<T>(T, int, InstantiateParameters, CancellationToken)
    Object.InstantiateAsync<T>(T, Vector3, Quaternion, InstantiateParameters, CancellationToken)
    Object.InstantiateAsync<T>(T, int, Vector3, Quaternion, InstantiateParameters, CancellationToken)
    Object.InstantiateAsync<T>(T, int, ReadOnlySpan<Vector3>, ReadOnlySpan<Quaternion>, InstantiateParameters, CancellationToken)
    Object.Instantiate(Object, Vector3, Quaternion)
    Object.Instantiate(Object, Vector3, Quaternion, Transform)
    Object.Instantiate(Object)
    Object.Instantiate(Object, Scene)
    Object.Instantiate<T>(T, InstantiateParameters)
    Object.Instantiate<T>(T, Vector3, Quaternion, InstantiateParameters)
    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.FindObjectsByType(Type, FindObjectsSortMode)
    Object.FindObjectsByType(Type, FindObjectsInactive, FindObjectsSortMode)
    Object.DontDestroyOnLoad(Object)
    Object.DestroyObject(Object, float)
    Object.DestroyObject(Object)
    Object.FindSceneObjectsOfType(Type)
    Object.FindObjectsOfTypeIncludingAssets(Type)
    Object.FindObjectsOfType<T>()
    Object.FindObjectsByType<T>(FindObjectsSortMode)
    Object.FindObjectsOfType<T>(bool)
    Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)
    Object.FindObjectOfType<T>()
    Object.FindObjectOfType<T>(bool)
    Object.FindFirstObjectByType<T>()
    Object.FindAnyObjectByType<T>()
    Object.FindFirstObjectByType<T>(FindObjectsInactive)
    Object.FindAnyObjectByType<T>(FindObjectsInactive)
    Object.FindObjectsOfTypeAll(Type)
    Object.FindObjectOfType(Type)
    Object.FindFirstObjectByType(Type)
    Object.FindAnyObjectByType(Type)
    Object.FindObjectOfType(Type, bool)
    Object.FindFirstObjectByType(Type, FindObjectsInactive)
    Object.FindAnyObjectByType(Type, FindObjectsInactive)
    Object.ToString()
    Object.name
    Object.hideFlags
    object.Equals(object, object)
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: UnityEngine.XR.OpenXR.Features.Meta
    Assembly: Unity.XR.MetaOpenXR.dll
    Syntax
    [OpenXRFeature(UiName = "Meta Quest: Colocation Discovery", BuildTargetGroups = new BuildTargetGroup[] { BuildTargetGroup.Android, BuildTargetGroup.Standalone }, Company = "Unity Technologies", Desc = "Enables you to advertise messages and discover colocated OpenXR Meta devices", DocumentationLink = "https://docs.unity3d.com/Packages/com.unity.xr.meta-openxr@2.2/manual/features/colocation-discovery.html", OpenxrExtensionStrings = "XR_META_colocation_discovery", Category = "Feature", FeatureId = "com.unity.openxr.feature.meta-colocation-discovery", Version = "1.0.0")]
    public class ColocationDiscoveryFeature : MetaOpenXRFeature

    Fields

    featureId

    The feature id string. This is used to give the feature a well known id for reference.

    Declaration
    public const string featureId = "com.unity.openxr.feature.meta-colocation-discovery"
    Field Value
    Type Description
    string

    Properties

    advertisementId

    The ID of the active Colocation Advertisement.

    Declaration
    public SerializableGuid advertisementId { get; }
    Property Value
    Type Description
    SerializableGuid

    advertisementState

    The current Colocation Advertisement ColocationState.

    Declaration
    public ColocationState advertisementState { get; }
    Property Value
    Type Description
    ColocationState

    discoveryState

    The current Colocation Discovery ColocationState.

    Declaration
    public ColocationState discoveryState { get; }
    Property Value
    Type Description
    ColocationState

    Methods

    OnInstanceCreate(ulong)

    Called after xrCreateInstance. Override this method to validate that any necessary OpenXR extensions were successfully enabled (OpenXRRuntime.IsExtensionEnabled) and that any required system properties are supported. If this method returns false, the feature's enabled property is set to false.

    Declaration
    protected override bool OnInstanceCreate(ulong xrInstance)
    Parameters
    Type Name Description
    ulong xrInstance

    Handle of the native xrInstance.

    Returns
    Type Description
    bool

    true if this feature successfully initialized. Otherwise, false.

    Overrides
    OpenXRFeature.OnInstanceCreate(ulong)
    Remarks

    If this feature is a required feature of an enabled feature set, returning false here causes the OpenXRLoader to fail, and XR Plug-in Management will fall back to another loader if enabled.

    See Also
    Enabling OpenXR spec extension strings

    OnInstanceDestroy(ulong)

    Called before xrDestroyInstance. Destroys the Colocation Advertisement and Discovery providers.

    Declaration
    protected override void OnInstanceDestroy(ulong xrInstance)
    Parameters
    Type Name Description
    ulong xrInstance

    Handle of the xrInstance

    Overrides
    OpenXRFeature.OnInstanceDestroy(ulong)

    TryStartAdvertisementAsync(Span<byte>)

    Attempts to start advertising, or broadcasting, the message to colocated users of your app that have Colocation Discovery active. If successful, the advertisementState will transition to Starting. Subscribe to advertisementStateChanged to know when advertisement has started and is active or if advertisement fails to start. Colocation Advertisement can only be started if the current advertisementState is Inactive. Calling TryStartAdvertisementAsync will return ValidationFailure if the current advertisement state is not Inactive.

    Declaration
    public Awaitable<Result<SerializableGuid>> TryStartAdvertisementAsync(Span<byte> message)
    Parameters
    Type Name Description
    Span<byte> message

    The message to advertise. The max buffer size is 1024 bytes.

    Returns
    Type Description
    Awaitable<Result<SerializableGuid>>

    The result of the request to start advertisement and the advertisement ID.

    TryStartDiscoveryAsync()

    Attempts to start discovery of any colocated users of your app that is actively advertising a message. If successful, the discoveryState will transition to Starting. Subscribe to discoveryStateChanged to know when discovery has started and is active or if discovery fails to start. Subscribe to messageDiscovered to know when a message is discovered. Colocation Discovery can only be started if the current discoveryState is Inactive. Calling TryStartDiscoveryAsync will return ValidationFailure if the current advertisement state is not Inactive.

    Declaration
    public Awaitable<XRResultStatus> TryStartDiscoveryAsync()
    Returns
    Type Description
    Awaitable<XRResultStatus>

    The result of the request to start discovery.

    TryStopAdvertisementAsync()

    Attempts to stop colocation advertisement. If successful, the advertisementState will transition to Stopping. Subscribe to advertisementStateChanged to know when advertisement has stopped and is inactive or if advertisement fails to stop. Colocation Advertisement can only be stopped if the current advertisementState is Active. Calling TryStopAdvertisementAsync will return ValidationFailure if the current advertisement state is not Inactive.

    Declaration
    public Awaitable<XRResultStatus> TryStopAdvertisementAsync()
    Returns
    Type Description
    Awaitable<XRResultStatus>

    The Awaitable of the async operation. You are responsible to await this.

    TryStopDiscoveryAsync()

    Attempts to Stops colocation discovery. If successful, the discoveryState will transition to Stopping. Subscribe to discoveryStateChanged to know when discovery has stopped and is inactive. Colocation Discovery can only be stopped if the current discoveryState is Active. Calling TryStartDiscoveryAsync will return ValidationFailure if the current advertisement state is not Inactive.

    Declaration
    public Awaitable<XRResultStatus> TryStopDiscoveryAsync()
    Returns
    Type Description
    Awaitable<XRResultStatus>

    The Awaitable of the async operation. You are responsible to await this.

    Events

    advertisementStateChanged

    Notifies when colocation advertisement state changes.

    Declaration
    public event EventHandler<Result<ColocationState>> advertisementStateChanged
    Event Type
    Type Description
    EventHandler<Result<ColocationState>>

    discoveryStateChanged

    Notifies when colocation discovery state changes.

    Declaration
    public event EventHandler<Result<ColocationState>> discoveryStateChanged
    Event Type
    Type Description
    EventHandler<Result<ColocationState>>

    messageDiscovered

    Notifies when a message was discovered while colocation discovery is Active. The data is allocated with Allocator.Temp and is automatically disposed of at the end of the frame.

    Declaration
    public event EventHandler<ColocationDiscoveryMessage> messageDiscovered
    Event Type
    Type Description
    EventHandler<ColocationDiscoveryMessage>
    In This Article
    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)