public void CreatePointOfReference(Vector3 pos, Quaternion rot) { m_PointOfReferenceCube.transform.position = pos; m_PointOfReferenceCube.transform.rotation = rot; #if UNITY_WSA if (store != null) { store.Delete(PointOfReferenceID); } if (m_PointOfReference) { DestroyImmediate(m_PointOfReference); } m_PointOfReference = m_PointOfReferenceCube.AddComponent <UnityEngine.XR.WSA.WorldAnchor>(); if (StatusText.Instance) { StatusText.Instance.SetText("Point of Reference Created"); } // SaveAnchorToStore(m_PointOfReferenceID, m_PointOfReference); StartCoroutine(SaveAnchor()); #endif }
public void StartPlacing() { if (anchorStore == null) { return; } UnityEngine.XR.WSA.WorldAnchor anchor = gameObject.GetComponent <UnityEngine.XR.WSA.WorldAnchor>(); if (anchor != null) { DestroyImmediate(anchor); } string[] ids = anchorStore.GetAllIds(); for (int index = 0; index < ids.Length; index++) { Debug.Log(ids[index]); if (ids[index] == ObjectAnchorStoreName) { bool deleted = anchorStore.Delete(ids[index]); Debug.Log("deleted: " + deleted); break; } } }
void PerformManipulationStart(Vector3 position) { manipulationPreviousPosition = position; UnityEngine.XR.WSA.WorldAnchor anchor = gameObject.GetComponent <UnityEngine.XR.WSA.WorldAnchor>(); if (anchor != null) { DestroyImmediate(anchor); } anchorStore.Delete(ObjectAnchorStoreName); }
public bool SetMarker(int marker) { int idx = marker - 1; if (marker > Markers.Count) { return(false); } //RaycastHit hitInfo; /*Physics.Raycast(Camera.main.transform.position, Camera.main.transform.forward, out hitInfo)*/ if (RosGazeManager.Instance.Focused) { if (anchorStore == null) { return(false); } // Delete WorldAnchor if selected marker currently has one UnityEngine.XR.WSA.WorldAnchor anchor = Markers[idx].GetComponent <UnityEngine.XR.WSA.WorldAnchor>(); if (anchor != null) { DestroyImmediate(anchor); } anchorStore.Delete(Markers[idx].name); // Move marker to new position Markers[idx].transform.position = RosGazeManager.Instance.position; // Set new WorldAnchor UnityEngine.XR.WSA.WorldAnchor attachingAnchor = Markers[idx].AddComponent <UnityEngine.XR.WSA.WorldAnchor>(); if (attachingAnchor.isLocated) { bool saved = anchorStore.Save(Markers[idx].name, attachingAnchor); Debug.Log("Saved new WorldAnchor position for " + Markers[idx].name + ": " + saved); } else { attachingAnchor.OnTrackingChanged += AttachingAnchor_OnTrackingChanged; } // return success return(true); } return(false); }
void OnSelect() { if (anchorStore == null) { return; } if (Placing) { UnityEngine.XR.WSA.WorldAnchor attachingAnchor = gameObject.AddComponent <UnityEngine.XR.WSA.WorldAnchor>(); if (attachingAnchor.isLocated) { Debug.Log("Saving persisted position immediately"); bool saved = anchorStore.Save(ObjectAnchorStoreName, attachingAnchor); Debug.Log("saved: " + saved); } else { attachingAnchor.OnTrackingChanged += AttachingAnchor_OnTrackingChanged; } } else { UnityEngine.XR.WSA.WorldAnchor anchor = gameObject.GetComponent <UnityEngine.XR.WSA.WorldAnchor>(); if (anchor != null) { DestroyImmediate(anchor); } string[] ids = anchorStore.GetAllIds(); for (int index = 0; index < ids.Length; index++) { Debug.Log(ids[index]); if (ids[index] == ObjectAnchorStoreName) { bool deleted = anchorStore.Delete(ids[index]); Debug.Log("deleted: " + deleted); break; } } } Placing = !Placing; }