UnityEngine.VR.WSA.Sharing.WorldAnchorTransferBatch.GetAllIds C# (CSharp) Method

GetAllIds() public method

Gets all of the identifiers currently mapped in this WorldAnchorTransferBatch. If the target array is not large enough to contain all the identifiers, then only those identifiers that fit within the array will be stored and the return value will equal the size of the array. You can detect this condition by checking for a return value less than WorldAnchorTransferBatch.anchorCount.

public GetAllIds ( string ids ) : int
ids string A target array to receive the identifiers of the currently mapped world anchors.
return int
        public int GetAllIds(string[] ids)
        {
            if (ids == null)
            {
                throw new ArgumentNullException("ids");
            }
            if (ids.Length > 0)
            {
                return GetAllIds_Internal(this.m_NativePtr, ids);
            }
            return 0;
        }

Same methods

WorldAnchorTransferBatch::GetAllIds ( ) : string[]

Usage Example

    /// <summary>
    /// Called when a remote anchor has been deserialized
    /// </summary>
    /// <param name="status">Tracks if the import worked</param>
    /// <param name="wat">The WorldAnchorTransferBatch that has the anchor information.</param>
    private void ImportComplete(SerializationCompletionReason status, WorldAnchorTransferBatch wat)
    {
        if (status == SerializationCompletionReason.Succeeded && wat.GetAllIds().Length > 0)
        {
            Debug.Log("Import complete");
            
            string first = wat.GetAllIds()[0];
            Debug.Log("Anchor name: " + first);

            WorldAnchor existingAnchor = objectToAnchor.GetComponent<WorldAnchor>();
            if (existingAnchor != null)
            {
                DestroyImmediate(existingAnchor);
            }

            WorldAnchor anchor = wat.LockObject(first, objectToAnchor);
            WorldAnchorManager.Instance.AnchorStore.Save(first, anchor);
            ImportInProgress = false;
            AnchorEstablished = true;
        }
        else
        {
            // if we failed, we can simply try again.
            gotOne = true;
            Debug.Log("Import fail");
        }
    }