A batch of WorldAnchors which can be exported and imported between apps.
private static IntPtr Create_Internal() { IntPtr result; WorldAnchorTransferBatch.INTERNAL_CALL_Create_Internal(out result); return(result); }
public WorldAnchor LockObject(string id, GameObject go) { WorldAnchor worldAnchor = go.GetComponent <WorldAnchor>(); bool flag = worldAnchor != null; if (worldAnchor == null) { worldAnchor = go.AddComponent <WorldAnchor>(); } WorldAnchor result; if (WorldAnchorTransferBatch.LoadAnchor_Internal(this.m_NativePtr, id, worldAnchor)) { result = worldAnchor; } else { if (!flag) { UnityEngine.Object.DestroyImmediate(worldAnchor); } result = null; } return(result); }
public void Dispose() { if (this.m_NativePtr != IntPtr.Zero) { WorldAnchorTransferBatch.Dispose_Internal(this.m_NativePtr); this.m_NativePtr = IntPtr.Zero; } GC.SuppressFinalize(this); }
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(WorldAnchorTransferBatch.AddWorldAnchor_Internal(this.m_NativePtr, id, anchor)); }
public static void ExportAsync(WorldAnchorTransferBatch transferBatch, SerializationDataAvailableDelegate onDataAvailable, SerializationCompleteDelegate onCompleted) { if (transferBatch == null) { throw new ArgumentNullException("transferBatch"); } if (onDataAvailable == null) { throw new ArgumentNullException("onDataAvailable"); } if (onCompleted == null) { throw new ArgumentNullException("onCompleted"); } ExportAsync_Internal(transferBatch.m_NativePtr, onDataAvailable, onCompleted); }
public static void ExportAsync(WorldAnchorTransferBatch transferBatch, WorldAnchorTransferBatch.SerializationDataAvailableDelegate onDataAvailable, WorldAnchorTransferBatch.SerializationCompleteDelegate onCompleted) { if (transferBatch == null) { throw new ArgumentNullException("transferBatch"); } if (onDataAvailable == null) { throw new ArgumentNullException("onDataAvailable"); } if (onCompleted == null) { throw new ArgumentNullException("onCompleted"); } WorldAnchorTransferBatch.ExportAsync_Internal(transferBatch.m_NativePtr, onDataAvailable, onCompleted); }
public int GetAllIds(string[] ids) { if (ids == null) { throw new ArgumentNullException("ids"); } int result; if (ids.Length > 0) { result = WorldAnchorTransferBatch.GetAllIds_Internal(this.m_NativePtr, ids); } else { result = 0; } return(result); }
public static void ImportAsync(byte[] serializedData, int offset, int length, WorldAnchorTransferBatch.DeserializationCompleteDelegate onComplete) { if (serializedData == null) { throw new ArgumentNullException("serializedData"); } if (serializedData.Length < 1) { throw new ArgumentException("serializedData is empty!", "serializedData"); } if (offset + length > serializedData.Length) { throw new ArgumentException("offset + length is greater that serializedData.Length!"); } if (onComplete == null) { throw new ArgumentNullException("onComplete"); } WorldAnchorTransferBatch.ImportAsync_Internal(serializedData, offset, length, onComplete); }
/// <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"); } }
/// <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); }
private static void InvokeWorldAnchorDeserializationCompleteDelegate(DeserializationCompleteDelegate onDeserializationComplete, SerializationCompletionReason completionReason, IntPtr nativePtr) { WorldAnchorTransferBatch deserializedTransferBatch = new WorldAnchorTransferBatch(nativePtr); onDeserializationComplete(completionReason, deserializedTransferBatch); }
public static void ImportAsync(byte[] serializedData, WorldAnchorTransferBatch.DeserializationCompleteDelegate onComplete) { WorldAnchorTransferBatch.ImportAsync(serializedData, 0, serializedData.Length, onComplete); }
public WorldAnchorTransferBatch() { this.m_NativePtr = WorldAnchorTransferBatch.Create_Internal(); }
private static void InvokeWorldAnchorDeserializationCompleteDelegate(WorldAnchorTransferBatch.DeserializationCompleteDelegate onDeserializationComplete, SerializationCompletionReason completionReason, IntPtr nativePtr) { WorldAnchorTransferBatch deserializedTransferBatch = new WorldAnchorTransferBatch(nativePtr); onDeserializationComplete(completionReason, deserializedTransferBatch); }