async void IOnClickListener.OnClick(View view) { if (!CanCreateAnchor()) { return; } createAnchorButton.Enabled = false; CloudSpatialAnchor cloudAnchor = new CloudSpatialAnchor(); cloudAnchor.LocalAnchor = PlacedVisual.LocalAnchor; cloudAnchor.AppProperties.Add("Shape", PlacedVisual.Shape.ToString()); isCreatingAnchor = true; await CloudAnchorManager.CreateAnchorAsync(cloudAnchor); if ((cloudAnchor.Identifier?.Length ?? 0) == 0) { OnAnchorCreationFailed?.Invoke(PlacedVisual, "Failed to create anchor"); return; } AnchorVisual createdAnchor = PlacedVisual; PlacedVisual = null; OnAnchorCreated?.Invoke(createdAnchor); }
public void RestoreAnchorsButtonClicked() { mLogger.CategoryLog(LogCategoryMethodIn); int anchorCount = CloudAnchorManager.Count; string anchorId = null; mCloudAnchorDic.Clear(); for (int i = 0; i < anchorCount; i++) { if (CloudAnchorManager.GetCloudAnchorId(i, out anchorId)) { XPSession.ResolveCloudAnchor(anchorId).ThenAction( delegate(CloudAnchorResult result) { XPAnchor xpAnchor = result.Anchor; if (xpAnchor != null) { AddAnchorGO(xpAnchor); } } ); } } mLogger.CategoryLog(LogCategoryMethodOut); }
private void Awake() { uI_InformPanelGameObject.SetActive(true); m_ARPlaneManager = GetComponent <ARPlaneManager>(); m_ARPlacementManager = GetComponent <ARPlacementManager>(); m_CloudAnchorManager = GetComponent <CloudAnchorManager>(); }
// Start is called before the first frame update void Start() { dropdownHandler = FindObjectOfType <DropdownHandler>(); uiManager = FindObjectOfType <UIManager>(); cloudAnchorManager = GetComponent <CloudAnchorManager>(); wayfinding = false; distanceToDestination = 0f; arrow = waypointPointer.transform.GetChild(0).GetChild(1).gameObject; }
// Start is called before the first frame update void Start() { arTapManager = FindObjectOfType <ARTapToPlace>(); cloudAnchorManager = FindObjectOfType <CloudAnchorManager>(); navManager = FindObjectOfType <NavManager>(); dropdownHandler = FindObjectOfType <DropdownHandler>(); AddAllCanvases(); activateDefaultView(); }
private void StartWatcher() { if (CloudAnchorManager.LocatingAnchors) { FragmentHelper.BackToPreviousFragment(Activity); } watcher = CloudAnchorManager.StartLocating(new AnchorLocateCriteria { NearDevice = new NearDeviceCriteria { DistanceInMeters = 8.0f, MaxResultCount = 25 } }); }
public void ListCloudAnchorButtonClicked() { mLogger.CategoryLog(LogCategoryMethodIn); mListCloudAnchorPanelGO.SetActive(true); GameObject cloudAnchorListContentGO = mListCloudAnchorPanelGO.transform.Find("CloudAnchorList/Viewport/Content").gameObject; // 一旦子要素を全て解放 string cloudAnchorId = null; for (int i = 0, size = cloudAnchorListContentGO.transform.childCount; i < size; i++) { GameObject childGO = cloudAnchorListContentGO.transform.GetChild(i).gameObject; Destroy(childGO); } cloudAnchorListContentGO.transform.DetachChildren(); int cloudAnchorCount = CloudAnchorManager.Count; // Scroll Viewの設定 float itemHeight = mListItemPrefab.GetComponent <LayoutElement>().preferredHeight; float itemVerticalSpace = cloudAnchorListContentGO.GetComponent <VerticalLayoutGroup>().spacing; cloudAnchorListContentGO.GetComponent <RectTransform>().sizeDelta = new Vector2(0, (itemHeight + itemVerticalSpace) * cloudAnchorCount); for (int i = 0, size = CloudAnchorManager.Count; i < size; i++) { if (CloudAnchorManager.GetCloudAnchorId(i, out cloudAnchorId)) { XPSession.ResolveCloudAnchor(cloudAnchorId).ThenAction((CloudAnchorResult result) => { XPAnchor xpAnchor = result.Anchor; if (xpAnchor != null) { // リストに追加 GameObject listItemGO = Instantiate(mListItemPrefab); //listItemGO.transform.Find("CloudAnchorId").gameObject.GetComponent<UnityEngine.UI.Text>().text = xpAnchor.CloudId; mLogger.CategoryLog(LogCategoryMethodTrace, "cloud anchor id = " + xpAnchor.CloudId); listItemGO.GetComponent <UnityEngine.UI.Text>().text = xpAnchor.CloudId; listItemGO.transform.SetParent(cloudAnchorListContentGO.transform); } }); } } mLogger.CategoryLog(LogCategoryMethodOut); }
async void IOnClickListener.OnClick(View view) { if (!CanCreateAnchor()) { return; } createAnchorButton.Enabled = false; CloudSpatialAnchor cloudAnchor = new CloudSpatialAnchor(); cloudAnchor.LocalAnchor = PlacedVisual.LocalAnchor; cloudAnchor.AppProperties.Add("Shape", PlacedVisual.Shape.ToString()); isCreatingAnchor = true; await CloudAnchorManager.CreateAnchorAsync(cloudAnchor) .ContinueWith(async cloudAnchorTask => { try { CloudSpatialAnchor anchor = await cloudAnchorTask; string anchorId = anchor.Identifier; Log.Debug("ASADemo", "anchorId: " + anchorId); var anchorSharingServiceClient = new AnchorSharingServiceClient(AccountDetails.AnchorSharingServiceUrl); SendAnchorResponse response = await anchorSharingServiceClient.SendAnchorIdAsync(anchorId); } catch (CloudSpatialException) { // to do //this.CreateAnchorExceptionCompletion($"{ex.Message}, {ex.ErrorCode}"); } catch (Exception) { // to do //this.CreateAnchorExceptionCompletion(ex.Message); //visual.SetColor(this, Color.Red); } }); AnchorVisual createdAnchor = PlacedVisual; PlacedVisual = null; OnAnchorCreated?.Invoke(createdAnchor); }
private void AddAnchorGO(XPAnchor xpAnchor, GameObject anchorGO = null, Anchor anchor = null) { mLogger.CategoryLog(LogCategoryMethodIn); if (anchorGO != null || !mCloudAnchorGODic.TryGetValue(xpAnchor.CloudId, out anchorGO)) { if (anchorGO == null) { anchorGO = Instantiate(mAnchorPrefab, xpAnchor.transform.position, xpAnchor.transform.rotation); } anchorGO.SetActive(true); mAnchorDic[xpAnchor.CloudId] = anchor; mCloudAnchorDic[xpAnchor.CloudId] = xpAnchor; mCloudAnchorGODic[xpAnchor.CloudId] = anchorGO; CloudAnchorManager.Append(xpAnchor.CloudId); } mLogger.CategoryLog(LogCategoryMethodOut); }
// Start is called before the first frame update void Start() { cloudAnchorManager = GetComponent <CloudAnchorManager>(); }