/// <summary> /// Saves the world anchor. /// </summary> /// <param name="gameObj">Anchored game object.</param> /// <param name="anchorSaved">Delegate invoked after the anchor gets saved.</param> public override void SaveWorldAnchor(GameObject gameObj, AnchorSavedDelegate anchorSaved) { Anchor anchor = gameObj != null?gameObj.GetComponent <Anchor>() : null; if (anchor == null) { anchor = gameObj != null?gameObj.GetComponentInParent <Anchor>() : null; } if (anchor == null) { //Debug.Log("Anchor not found on object or parent"); if (anchorSaved != null) { anchorSaved(string.Empty, "AnchorNotFound"); } return; } //Debug.Log("Saving cloud anchor..."); XPSession.CreateCloudAnchor(anchor).ThenAction(result => { //Debug.Log("Saving cloud anchor complete. Result: " + result.Response + ", cloudId: " + (result.Anchor != null ? result.Anchor.CloudId : null)); if (anchorSaved != null) { anchorSaved(result.Response == CloudServiceResponse.Success ? result.Anchor.CloudId : string.Empty, result.Response == CloudServiceResponse.Success ? string.Empty : result.Response.ToString()); } }); }
/// <summary> /// Saves the world anchor. /// </summary> /// <param name="gameObj">Anchored game object.</param> /// <param name="anchorSaved">Delegate invoked after the anchor gets saved.</param> public void SaveWorldAnchor(GameObject gameObj, AnchorSavedDelegate anchorSaved) { if (arInterface != null) { arInterface.SaveWorldAnchor(gameObj, anchorSaved); } }
public virtual void SaveWorldAnchor(GameObject gameObj, AnchorSavedDelegate anchorSaved) { if (anchorSaved != null) { anchorSaved(string.Empty, "SaveAnchorNotSupported"); } }
public override void SaveWorldAnchor(GameObject gameObj, AnchorSavedDelegate anchorSaved) { if (isDisplayOpaque) { base.SaveWorldAnchor(gameObj, anchorSaved); return; } WorldAnchor anchor = gameObj != null?gameObj.GetComponent <WorldAnchor>() : null; if (anchor == null) { anchor = gameObj != null?gameObj.GetComponentInParent <WorldAnchor>() : null; } if (anchor == null) { if (anchorSaved != null) { anchorSaved(string.Empty, "AnchorNotFound"); } return; } // init buffer InitMemBuffer(MemBufferLength); string anchorId = anchor.gameObject.name; WorldAnchorTransferBatch transferBatch = new WorldAnchorTransferBatch(); transferBatch.AddWorldAnchor(anchorId, anchor); WorldAnchorTransferBatch.ExportAsync(transferBatch, (data) => { WriteMemBuffer(data); }, (result) => { if (anchorSaved != null) { anchorSaved(result == SerializationCompletionReason.Succeeded ? anchorId : string.Empty, result == SerializationCompletionReason.Succeeded ? string.Empty : result.ToString()); } }); }
/// <summary> /// Saves the world anchor. /// </summary> /// <param name="gameObj">Anchored game object.</param> /// <param name="anchorSaved">Delegate invoked after the anchor gets saved.</param> public override void SaveWorldAnchor(GameObject gameObj, AnchorSavedDelegate anchorSaved) { if (gameObj == null) { if (anchorSaved != null) { anchorSaved(string.Empty, "AnchorNotFound"); } return; } Transform anchorTrans = gameObj.transform.parent != null ? gameObj.transform.parent : gameObj.transform; Pose anchorPose = new Pose(anchorTrans.position, anchorTrans.rotation); GoogleARCore.CrossPlatform.XPSession.CreateCloudAnchor(anchorPose).ThenAction(result => { if (anchorSaved != null) { anchorSaved(result.Response == GoogleARCore.CrossPlatform.CloudServiceResponse.Success ? result.Anchor.CloudId : string.Empty, result.Response == GoogleARCore.CrossPlatform.CloudServiceResponse.Success ? string.Empty : result.Response.ToString()); } }); }