예제 #1
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");
        }
    }