public void DeleteSelectedMolecule() { if (_lastSelectedMol != null) { uIController.TurnOffToggles(); _lastSelectedMol.Dehighlight(); _lastSelectedMol.Destroy(); } }
public void Update() { _UpdateApplicationLifecycle(); // Hide snackbar when currently tracking at least one plane. Session.GetTrackables <DetectedPlane>(m_AllPlanes); bool showSearchingUI = true; for (int i = 0; i < m_AllPlanes.Count; i++) { if (m_AllPlanes[i].TrackingState == TrackingState.Tracking) { showSearchingUI = false; break; } } if (showSearchingUI != uIController.SearchingForPlanes) { if (firstSurface == true) { ChemviewHelper.ShowAndroidToastMessage("Double tap on a surface to spawn a molecule"); firstSurface = false; } uIController.SearchingForPlanes = showSearchingUI; SearchingForPlaneUI.GetComponent <SearchingForPlaneController>().MovePosition(showSearchingUI); if (showSearchingUI) { SearchingForPlaneUI.GetComponent <SearchingForPlaneController>().StartMessageCoroutine(); uIController.FadeOut(); } else { uIController.FadeIn(); } } Touch touch; // If the player has not touched the screen, we are done with this update. if (Input.touchCount < 1 || (touch = Input.GetTouch(0)).phase != TouchPhase.Began) { return; } if (touch.tapCount == 1 && UserRotating == false) { if (!EventSystem.current.IsPointerOverGameObject(touch.fingerId)) { Ray raycast = FirstPersonCamera.ScreenPointToRay(touch.position); RaycastHit raycastHit; if (Physics.Raycast(raycast, out raycastHit)) { if (raycastHit.collider.tag == "Molecule" && UserRotating == false) { if (selectedMol == null) { selectedMol = raycastHit.collider.GetComponentInChildren <MoleculeController>(); _lastSelectedMol = selectedMol; selectedMol.isSelected = true; selectedMol.Highlight(); uIController.SetToggles(selectedMol); } else { if (selectedMol != raycastHit.collider.GetComponentInChildren <MoleculeController>()) { selectedMol.Dehighlight(); UserRotating = false; uIController.TurnOffToggles(); selectedMol = raycastHit.collider.GetComponentInChildren <MoleculeController>(); _lastSelectedMol = selectedMol; selectedMol.isSelected = true; selectedMol.Highlight(); uIController.SetToggles(selectedMol); } } } } else { if (selectedMol != null && UserRotating == false) { selectedMol.Dehighlight(); MoleculeController selectedMolScript = selectedMol.GetComponentInChildren <MoleculeController>(); selectedMolScript.isSelected = false; selectedMol = null; uIController.TurnOffToggles(); UserRotating = false; } } return; } } if (touch.tapCount == 2) { if (!EventSystem.current.IsPointerOverGameObject(touch.fingerId) && UserRotating == false) { SpawnMolecule(); return; } } }
public void Update() { _UpdateApplicationLifecycle(); // Hide snackbar when currently tracking at least one plane. Session.GetTrackables <DetectedPlane>(m_AllPlanes); bool showSearchingUI = true; for (int i = 0; i < m_AllPlanes.Count; i++) { if (m_AllPlanes[i].TrackingState == TrackingState.Tracking) { showSearchingUI = false; break; } } SearchingForPlaneUI.SetActive(showSearchingUI); Touch touch; // If the player has not touched the screen, we are done with this update. if (Input.touchCount < 1 || (touch = Input.GetTouch(0)).phase != TouchPhase.Began) { return; } if (touch.tapCount == 1) { if (!EventSystem.current.IsPointerOverGameObject(touch.fingerId)) { Ray raycast = FirstPersonCamera.ScreenPointToRay(touch.position); RaycastHit raycastHit; if (Physics.Raycast(raycast, out raycastHit)) { if (raycastHit.collider.tag == "Molecule" && UserRotating == false) { if (selectedMol == null) { selectedMol = raycastHit.collider.GetComponent <MoleculeController>(); MoleculeController selectedMolScript = selectedMol.GetComponent <MoleculeController>(); selectedMolScript.isSelected = true; selectedMol.Highlight(); } else { selectedMol.Dehighlight(); selectedMol = raycastHit.collider.GetComponent <MoleculeController>(); MoleculeController selectedMolScript = selectedMol.GetComponent <MoleculeController>(); selectedMolScript.isSelected = true; selectedMol.Highlight(); } } } else { if (selectedMol != null && UserRotating == false) { selectedMol.Dehighlight(); MoleculeController selectedMolScript = selectedMol.GetComponent <MoleculeController>(); selectedMolScript.isSelected = false; selectedMol = null; } } return; } } if (touch.tapCount == 2) { if (!EventSystem.current.IsPointerOverGameObject(touch.fingerId) && UserRotating == false) { _ShowAndroidToastMessage("mol Spawned"); SpawnMolecule(); return; } } }