/* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. * * Licensed under the Oculus SDK License Agreement (the "License"); * you may not use the Oculus SDK except in compliance with the License, * which is provided at the time of installation or download, or which * otherwise accompanies this software in either electronic or hard copy form. * * You may obtain a copy of the License at * * https://developer.oculus.com/licenses/oculussdk/ * * Unless required by applicable law or agreed to in writing, the Oculus SDK * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /// /// Represents a user for purposes of sharing scene anchors. /// /// /// In order to share an anchor, you need to specify the user or users with whom you'd like to share those anchor(s). /// /// A "space user" represents an Oculus user and is used by the following methods: /// - /// - /// - /// - /// - /// - /// /// An is a lightweight struct that wraps a native handle to a space user. You can create /// an from the user id of an Oculus user obtained from the /// [Platform SDK](https://developer.oculus.com/documentation/unity/ps-platform-intro/). /// public struct OVRSpaceUser : System.IDisposable { /// /// Tries to create a handle to a specific Oculus user in the current conceptual space. /// /// /// A user's unique ID provided by a support platform, i.e. the org-unique Oculus user ID. /// You must request these IDs e.g. from the /// Platform SDK.
/// See also: Oculus.Platform.Users module. /// /// /// The result of the space user creation request; will only be iff this method returned true. /// /// /// true iff is a handle to a user in the current space. /// /// /// should not represent the numerical value 0. /// This is a common value to inadvertently obtain, usually in cases involving insufficient app, user, or device permissions. /// public static bool TryCreate(ulong platformUserId, out OVRSpaceUser spaceUser) { spaceUser = new OVRSpaceUser(); return OVRPlugin.CreateSpaceUser(platformUserId, out spaceUser._handle); } /// /// Tries to create a handle to a specific Oculus user in the current conceptual space. /// /// /// A user's unique ID provided by a support platform, i.e. the org-unique Oculus user ID. /// You must request these IDs e.g. from the /// Platform SDK.
/// See also: Oculus.Platform.Users module. /// /// /// The result of the space user creation request; will only be iff this method returned true. /// /// /// true if is a valid handle to a user in the current space.
/// false may be returned if is null or could not be parsed as a numerical ID. ///
/// /// should not represent the numerical value 0. /// This is a common value to inadvertently obtain, usually in cases involving insufficient app, user, or device permissions. /// public static bool TryCreate(string platformUserId, out OVRSpaceUser spaceUser) { if (ulong.TryParse(platformUserId, out ulong parsed)) return TryCreate(parsed, out spaceUser); spaceUser = default; return false; } /// /// Checks if this is a valid handle to an authenticated space user. /// /// /// The may be invalid if it has been disposed () or if creation /// fails. /// /// For example: /// /// public bool Valid => _handle != 0 && Id != 0; /// /// Creates a handle for a specific platform user in the current conceptual space. /// /// /// A user's unique ID provided by a support platform, i.e. the org-unique Oculus user ID. /// You must request these IDs e.g. from the /// Platform SDK.
/// See also: Oculus.Platform.Users module. /// /// /// This constructor does not perform any kind of validation. /// You should consider checking the property after construction, /// or use the static method instead. /// [System.Obsolete("Constructor ignores validation. Use TryCreate(*) methods instead.", error: false)] public OVRSpaceUser(ulong spaceUserId) { _ = OVRPlugin.CreateSpaceUser(spaceUserId, out _handle); } /// /// The org-unique Oculus user ID associated with this . /// /// /// This property is the `spaceUserId` argument provided to the constructor, or zero /// if the is not valid ( is false). /// public ulong Id => _handle == 0 ? 0 : OVRPlugin.GetSpaceUserId(_handle, out var userId) ? userId : 0; /// /// Disposes of the . /// /// /// This method does not destroy the user account. It disposes the handle used to reference it. /// public void Dispose() { if (_handle == 0) return; OVRPlugin.DestroySpaceUser(_handle); _handle = 0; } internal ulong _handle; }