/* * 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. */ using System; /// /// Represents a "space" in the Oculus Runtime. /// public readonly struct OVRSpace : IEquatable { /// /// A runtime handle associated with this . This could change between subsequent sessions /// or apps. /// public ulong Handle { get; } /// /// Retrieve the universally unique identifier (UUID) associated with this . /// /// /// Every space that can be persisted will have a UUID associated with it. UUIDs are consistent across different /// sessions and apps. /// /// The UUID of a space does not change over time, but not all spaces are guaranteed to have a UUID. /// /// If successful, the uuid associated with this , otherwise, `Guid.Empty`. /// /// Returns `true` if the uuid could be retrieved, otherwise `false`. public bool TryGetUuid(out Guid uuid) => OVRPlugin.GetSpaceUuid(Handle, out uuid); /// /// Indicates whether this represents a valid space (vs a default constructed /// ). /// public bool Valid => Handle != 0; /// /// Constructs an object from an existing runtime handle and UUID. /// /// /// This constructor does not create a new space. An is a wrapper for low-level functionality /// in the Oculus Runtime. To create a new spatial anchor, use . /// /// The runtime handle associated with the space. public OVRSpace(ulong handle) => Handle = handle; /// /// Generates a string representation of this of the form /// "0xYYYYYYYY" /// where "Y" are the hexadecimal digits of the . /// /// Returns a string representation of this . public override string ToString() => $"0x{Handle:x8}"; public bool Equals(OVRSpace other) => Handle == other.Handle; public override bool Equals(object obj) => obj is OVRSpace other && Equals(other); public override int GetHashCode() => Handle.GetHashCode(); public static bool operator== (OVRSpace lhs, OVRSpace rhs) => lhs.Handle == rhs.Handle; public static bool operator!= (OVRSpace lhs, OVRSpace rhs) => lhs.Handle != rhs.Handle; public static implicit operator OVRSpace(ulong handle) => new OVRSpace(handle); public static implicit operator ulong(OVRSpace space) => space.Handle; }