Example #1
0
 /// <summary>
 /// The Unity Update() method.
 /// </summary>
 ///
 public void MoleculeSpinToggle(bool newValue)
 {
     if (selectedMol != null)
     {
         MoleculeController selectedMolScript = selectedMol.GetComponent <MoleculeController>();
         selectedMolScript.rotateMolecule = newValue;
     }
 }
Example #2
0
    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;
            }
        }
    }