private AnchorMarker CreateNewMarker(string newMarkerId) { Vector3 hitPoint = Camera.main.transform.position + Camera.main.transform.forward; Vector3 directionToCamera = -Camera.main.transform.forward; directionToCamera.y = 0f; GameObject marker = (GameObject)Instantiate(WorldAnchorMarker, hitPoint, Quaternion.LookRotation(directionToCamera)); AnchorMarker anchorMarker = marker.GetComponent <AnchorMarker>(); anchorMarker.Init(newMarkerId, worldAnchorManager); anchorMarker.AttachAnchor(); return(anchorMarker); }
private void WorldAnchorStoreLoaded(WorldAnchorStore store) { Debug.Log("AnchorPlacer: WorldAnchorStoreLoaded"); string[] anchorIdsInStore = store.GetAllIds(); List <string> persistedAnchorMarkerIdsToRemove = new List <string>(); foreach (string persistedMarkerId in PersistedAnchorMarkersIds) { bool markerIdInAnchorStore = Array.Exists(anchorIdsInStore, id => id == persistedMarkerId); bool markerIdShouldBeSpawned = markerIdInAnchorStore && (persistedMarkerId == ANCHOR_VIVE_ORIGIN); if (markerIdShouldBeSpawned) { Debug.Log("Reload Marker from store with id [" + persistedMarkerId + "]"); GameObject markerClone = (GameObject)Instantiate(WorldAnchorMarker, Vector3.zero, Quaternion.identity); AnchorMarker anchorMarker = markerClone.GetComponent <AnchorMarker>(); anchorMarker.Init(persistedMarkerId, worldAnchorManager); anchorMarker.AttachAnchor(); Markers.Add(anchorMarker.gameObject); MarkerViveOrigin = anchorMarker; } else { Debug.Log("Marker with id [" + persistedMarkerId + "] was not found in AnchorStore"); persistedAnchorMarkerIdsToRemove.Add(persistedMarkerId); } } foreach (string persistedMarkerIdToRemove in persistedAnchorMarkerIdsToRemove) { Debug.Log("Removing marker with id [" + persistedMarkerIdToRemove + "]"); PersistedAnchorMarkersIds.Remove(persistedMarkerIdToRemove); } SaveMarkersToFile(); }