// Update is called once per frame void Update() { if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began) { GameObject clone = Instantiate(prefabObject, Camera.main.transform.position + (this.distanceFromCamera * Camera.main.transform.forward), Quaternion.identity); UnityARUserAnchorComponent component = clone.GetComponent <UnityARUserAnchorComponent>(); AddMessage(clone, component.AnchorId); // delete this if you don't want to remove object testId = component.AnchorId; testMsg = (Message)m_messages[testId]; m_TimeUntilRemove = 5f; } // delete this also /*m_TimeUntilRemove -= Time.deltaTime; * if (m_TimeUntilRemove <= 0.0f) * { * if (m_Clones.Contains(testId)) * { * RemoveMessage(testId); * m_TimeUntilRecreate = 5f; * } * * m_TimeUntilRecreate -= Time.deltaTime; * if (m_TimeUntilRecreate <= 0.0f && recreateFlag) { * Vector3 targetPosition = LocationHelper.calculatePosition(locationManager.getOrigWorldPosition(), testMsg.m_worldPosition); * Console.WriteLine("Recalculated Target Location: X: " + targetPosition.x + " Y: " + targetPosition.y + * " Z: " + targetPosition.z); * GameObject recreateObj = Instantiate(prefabObject, targetPosition, testMsg.m_rotation); * UnityARUserAnchorComponent component = recreateObj.GetComponent<UnityARUserAnchorComponent>(); * m_Clones.Add(component.AnchorId); * recreateFlag = false; * } * }*/ }
/// <summary> /// <b>(iOS only)</b>Attempts to asynchronously host a new <see cref="Cloud Anchor"/>. /// </summary> /// <param name="anchor">The anchor to host.</param> /// <returns> /// A task that will complete when the attempt to host a new <see cref="Cloud Anchor"/> has finished. /// The result will be a <see cref="CloudAnchorResult"/> associated with the operation. /// </returns> public static AsyncTask <CloudAnchorResult> CreateCloudAnchor( UnityARUserAnchorComponent anchor) { return(CloudServiceManager.Instance.CreateCloudAnchor( new Pose(anchor.transform.position, anchor.transform.rotation))); }
/// <summary> /// <b>(iOS only)</b>Attempts to asynchronously create a new <see cref="Cloud Anchor"/> /// with a given lifetime in days, using the pose of the provided <paramref name="anchor"/>. /// </summary> /// <remarks> /// The initial pose of the returned anchor will be set to the pose of the provided /// <paramref name="anchor"/>. However, the returned anchor is completely independent of /// the original <paramref name="anchor"/>, and the two poses might diverge over time. /// Hosting requires an active session for which the <see cref="ARTrackingState"/> is /// <see cref="ARTrackingState.ARTrackingStateNormal"/>, as well as a working internet /// connection. The task will continue to retry silently in the background if it is unable /// to establish a connection to the ARCore <see cref="Cloud Anchor"/> service. /// </remarks> /// <param name="anchor">The anchor to host.</param> /// <param name="ttlDays">The lifetime of the anchor in days. Must be positive. The /// maximum allowed value is 1 if using an API Key to authenticate with the /// ARCore <see cref="Cloud Anchor"/> service, otherwise the maximum allowed value is 365.</param> /// <returns>A task that will complete when the attempt to create a new <see cref="Cloud Anchor"/> has /// finished. The result will be a <c>CloudAnchorResult</c> associated with the operation. /// </returns> public static GoogleARCore.AsyncTask <CloudAnchorResult> CreateCloudAnchor( UnityARUserAnchorComponent anchor, int ttlDays) { return(CloudServiceManager.Instance.CreateCloudAnchor( new Pose(anchor.transform.position, anchor.transform.rotation), ttlDays)); }
/// <summary> /// Gets the ARKit anchor pointer. /// </summary> /// <param name="anchorComponent">The anchor component.</param> /// <returns><see cref="IntPtr"/>.</returns> public static IntPtr GetAnchorPointer(this UnityARUserAnchorComponent anchorComponent) { return(UnityARSessionNativeInterface.GetARSessionNativeInterface().GetAnchorPointerFromId(anchorComponent.AnchorId)); }
public void SetPlacedAnchorRoot(bool trackable, UnityARUserAnchorComponent anchor) { _isTrackable.Value = trackable; _placedAnchorRoot.Value = anchor; }