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

AddWorldAnchor() public method

Adds a WorldAnchor to the batch with the specified identifier.

public AddWorldAnchor ( string id, WorldAnchor anchor ) : bool
id string The identifier associated with this anchor in the batch. This must be unique per batch.
anchor UnityEngine.VR.WSA.WorldAnchor The anchor to add to the batch.
return bool
        public bool AddWorldAnchor(string id, WorldAnchor anchor)
        {
            if (string.IsNullOrEmpty(id))
            {
                throw new ArgumentException("id is null or empty!", "id");
            }
            if (anchor == null)
            {
                throw new ArgumentNullException("anchor");
            }
            return AddWorldAnchor_Internal(this.m_NativePtr, id, anchor);
        }

Usage Example

    /// <summary>
    /// If we are supposed to create the anchor for export, this is the function to call.
    /// </summary>
    public void CreateAnchor()
    {
        objectToAnchor = SharedCollection.Instance.gameObject;
        WorldAnchorTransferBatch watb = new WorldAnchorTransferBatch();
        WorldAnchor worldAnchor = objectToAnchor.GetComponent<WorldAnchor>();
        if (worldAnchor == null)
        {
            worldAnchor = objectToAnchor.AddComponent<WorldAnchor>();
        }

        exportingAnchorName = Guid.NewGuid().ToString();
        Debug.Log("exporting " + exportingAnchorName);
        watb.AddWorldAnchor(exportingAnchorName, worldAnchor);
        WorldAnchorTransferBatch.ExportAsync(watb, WriteBuffer, ExportComplete);
    }