private bool PlaceGeospatialAnchor(GeospatialAnchorHistory history) { Quaternion quaternion = Quaternion.AngleAxis(180f - (float)history.Heading, Vector3.up); var anchor = AnchorManager.AddAnchor( history.Latitude, history.Longitude, history.Altitude, quaternion); if (anchor != null) { GameObject anchorGO = Instantiate(GeospatialPrefab, anchor.transform); _anchorObjects.Add(anchorGO); return(true); } return(false); }
/// <summary> /// Callback handling "Set Anchor" button click event in AR View. /// </summary> public void OnSetAnchorClicked() { var pose = EarthManager.CameraGeospatialPose; GeospatialAnchorHistory history = new GeospatialAnchorHistory( pose.Latitude, pose.Longitude, pose.Altitude, pose.Heading); if (PlaceGeospatialAnchor(history)) { _historyCollection.Collection.Add(history); SnackBarText.text = $"{_anchorObjects.Count} Anchor(s) Set!"; } else { SnackBarText.text = "Failed to set an anchor!"; } ClearAllButton.gameObject.SetActive(_historyCollection.Collection.Count > 0); SaveGeospatialAnchorHistory(); }