Ejemplo n.º 1
0
    protected void OnPointerClick(PointerEventData eventData)
    {
        if (Mode != PVMode.Delete)
        {
            return;
        }

        var touchPosition = eventData.pressPosition;
        var ray           = Camera.main.ScreenPointToRay(touchPosition);

        RaycastHit hit;

        if (Physics.Raycast(ray, out hit))
        {
            if (hit.transform.gameObject != null)
            {
                GameObject touchedObject = hit.transform.gameObject;
                Debug.Log("MobilePhysicalVisualizerManager::OnPointerClick - Touched " + touchedObject.transform.name);

                var selectable = touchedObject.GetComponent <SelectableSensor>();

                if (selectable == null)
                {
                    Debug.Log("MobilePhysicalVisualizerManager::OnPointerClick - Selectable sensor not found" + touchedObject.transform.name);
                    return;
                }

                selectable.IsSelected = true;

                StartCoroutine(UpdateSelectionStates(touchedObject));

                SelectedAnchor = touchedObject;

                string message = "Are you sure you want to delete this anchor?";

                ConfirmationDialog.ShowDialog(ConfirmationDialogPrefab, DialogParent, message, (result) =>
                {
                    Debug.Log(string.Format("Delete dialog closed, result: {0}", result));

                    if (result && SelectedAnchor != null)
                    {
                        ShowLoadingIndicator("Deleting anchor...");

                        var panel       = SelectedAnchor.GetComponent <ProximityVisibility>().Object;
                        var cloudAnchor = SelectedAnchor.GetComponent <AnchorBinding>().Anchor;

                        _anchorManager.DeleteAnchor(SelectedAnchor, panel, cloudAnchor);
                    }
                });
            }
        }
    }
    private void OnDeleteDialogClosed(DialogResult result)
    {
        if (result.Result == DialogButtonType.Yes)
        {
            ShowLoadingIndicator("Deleting anchor...");

            var panel       = SelectedAnchor.GetComponent <ProximityVisibility>().Object;
            var cloudAnchor = SelectedAnchor.GetComponent <AnchorBinding>().Anchor;

            _anchorManager.DeleteAnchor(SelectedAnchor, panel, cloudAnchor);
        }

        SelectedAnchor = null;
        StartCoroutine(UpdateSelectionStates(null));
    }