コード例 #1
0
 // Converts uuid to string in this format "e875df5e-3f47-4a8f-b0a5-9ca79280b27d"
 private string GetUuidString(OVRPlugin.SpatialEntityUuid uuid)
 {
     byte[] uuidData = new byte[16];
     BitConverter.GetBytes(uuid.Value_0).CopyTo(uuidData, 0);
     BitConverter.GetBytes(uuid.Value_1).CopyTo(uuidData, 8);
     return(AnchorHelpers.UuidToString(uuidData));
 }
コード例 #2
0
    public void QueryAnchorByUuid()
    {
        // Get number of saved anchor uuids
        if (!PlayerPrefs.HasKey(numUuids))
        {
            PlayerPrefs.SetInt(numUuids, 0);
        }
        int playerNumUuids = PlayerPrefs.GetInt("numUuids");

        Log("numUuids to query with: " + numUuids + " uuids ");
        if (playerNumUuids == 0)
        {
            return;
        }


        OVRPlugin.SpatialEntityUuid[] uuidArr = new OVRPlugin.SpatialEntityUuid[playerNumUuids];
        for (int i = 0; i < playerNumUuids; ++i)
        {
            string uuidKey     = "uuid" + i;
            string currentUuid = PlayerPrefs.GetString(uuidKey);
            Log("QueryAnchorByUuid: " + currentUuid);

            var byteArray = AnchorHelpers.StringToUuid(currentUuid);
            uuidArr[i] = new OVRPlugin.SpatialEntityUuid
            {
                Value_0 = BitConverter.ToUInt64(byteArray, 0),
                Value_1 = BitConverter.ToUInt64(byteArray, 8)
            };
        }

        var uuidInfo = new OVRPlugin.SpatialEntityFilterInfoIds
        {
            NumIds = playerNumUuids,
            Ids    = uuidArr
        };

        var queryInfo = new OVRPlugin.SpatialEntityQueryInfo()
        {
            QueryType      = OVRPlugin.SpatialEntityQueryType.Action,
            MaxQuerySpaces = 20,
            Timeout        = 0,
            Location       = OVRPlugin.SpatialEntityStorageLocation.Local,
            ActionType     = OVRPlugin.SpatialEntityQueryActionType.Load,
            FilterType     = OVRPlugin.SpatialEntityQueryFilterType.Ids,
            IdInfo         = uuidInfo
        };

        ulong newReqId = 0;

        if (!OVRPlugin.SpatialEntityQuerySpatialEntity(queryInfo, ref newReqId))
        {
            Log("OVRPlugin.SpatialEntityQuerySpatialEntity initiated");
        }
    }
        /// <summary>
        /// Gets the cloud anchors pose.
        /// </summary>
        /// <param name="cloudAnchor">
        /// The cloud anchor to return the pose for.
        /// </param>
        /// <returns><see cref="Pose"/>
        /// The anchors pose.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">
        /// Thrown if <paramref name="gameObject"/> is <see langword = "null" />.
        /// </exception>
        /// <exception cref="PlatformNotSupportedException">
        /// Thrown if the current platform is not supported by the SDK.
        /// </exception>
        static public Pose GetPose(this CloudSpatialAnchor cloudAnchor)
        {
            // Validate
            if (cloudAnchor == null)
            {
                throw new ArgumentNullException(nameof(cloudAnchor));
            }

            // Placeholder
            Pose anchorPose = Pose.identity;

#if UNITY_ANDROID || UNITY_IOS
            return(AnchorHelpers.GetPose(cloudAnchor));
#else
            throw new PlatformNotSupportedException($"Platform is not supported.");
#endif
        }