示例#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");
        }
    }
示例#3
0
    // Save callback
    private void SpatialAnchorSaved(UInt64 requestId, UInt64 space, bool result, OVRPlugin.SpatialEntityUuid uuid)
    {
        Log("SpatialAnchorSaved requestId: " + requestId + " space: " + space + " result: " + result + " uuid: " + GetUuidString(uuid));

        // Write uuid of saved anchor to file
        if (!PlayerPrefs.HasKey(numUuids))
        {
            PlayerPrefs.SetInt(numUuids, 0);
        }
        int playerNumUuids = PlayerPrefs.GetInt(numUuids);

        PlayerPrefs.SetString("uuid" + playerNumUuids, GetUuidString(uuid));
        PlayerPrefs.SetInt(numUuids, ++playerNumUuids);

        // Toggle local save icon
        if (handleToAnchor.ContainsKey(space))
        {
            handleToAnchor[space].ShowSaveIcon();
        }
    }
示例#4
0
 // Erase callback
 private void SpatialEntityStorageErase(UInt64 requestId, bool result, OVRPlugin.SpatialEntityUuid uuid, OVRPlugin.SpatialEntityStorageLocation location)
 {
     Log("SpatialEntityStorageErase requestID: " + requestId + " result: " + result + " uuid: " + GetUuidString(uuid) + " location: " + location);
 }