Пример #1
0
    void Update()
    {
        if (CardboardMagnetSensor.CheckIfWasClicked())
        {
            Ray        ray;
            RaycastHit hit;
            ray = Camera.main.ScreenPointToRay(Input.mousePosition);

            bool collide = Physics.Raycast(ray, out hit); //est ce que ça touche un truc ?
                                                          //il faut utiliser un physic raycast ou un graphic?


            if (collide)
            {
                if (hit.collider.tag == "Button")
                {
                    Button bouton = hit.collider.GetComponentInParent <Button>();
                    bouton.onClick.Invoke();
                    Debug.Log("Ca touche un bouton");
                }
                else
                {
                    Debug.Log("Ca touche pas un bouton");
                }
            }
            else
            {
                Debug.Log("Ca touche rien");
            }


            CardboardMagnetSensor.Reset();
        }
    }
Пример #2
0
    void Update()
    {
        if (!magnetDetectionEnabled)
        {
            return;
        }
        if (CardboardMagnetSensor.CheckIfWasClicked())
        {
            ///PARTIE IMPROVISEE
            RaycastHit hit;
            Ray        ray     = Camera.main.ScreenPointToRay(Input.mousePosition);
            bool       collide = Physics.Raycast(ray, out hit); //merci doc unity
            if (collide && hit.collider.tag == "button")        // hit est pas initialisé
            {
                Transform objectHit = hit.transform;
                Debug.Log("Youpi !");
                //GameObject collidedGameObject = hit.collider.gameObject;//on récupère l'objet auquel appartien le collider :D
                //callbackObject = collidedGameObject.GetComponent<TypeDeLObjet>();//on récupère l'objet contenant l'action à effectuer ( ce que tu appèlle avec le Onclic je pense)
                //callbackObject.OnClick();//on appèle la callback sans fautes d'orthographe ;)
                //ChangeScene blabla = this.gameObject.GetComponent<ChangeScene>();
                GameObject collidedGameObject = hit.collider.gameObject;
                //collidedGameObject.GetComponent<SceneChanger>().Change();// ça c'est ok
            }
            ///
            Debug.Log("DO SOMETHING HERE");  // PERFORM ACTION.

            CardboardMagnetSensor.ResetClick();
        }
    }
Пример #3
0
 void Update()
 {
     if (CardboardMagnetSensor.CheckIfWasClicked() || Input.GetMouseButtonDown(0))
     {
         gameManager.IsOn_Magnet = true;
         CardboardMagnetSensor.ResetClick();
     }
 }
Пример #4
0
    void Update()
    {
        if (CardboardMagnetSensor.CheckIfWasClicked())
        {
            gameManager.IsOnMagnet = true;

            CardboardMagnetSensor.ResetClick();
        }
    }
Пример #5
0
    private void Update()
    {
        if (CardboardMagnetSensor.CheckIfWasClicked() || Input.GetMouseButtonDown(0))
        {
            GameObject clone = Instantiate(box_prefab);

            float fx = UnityEngine.Random.Range(-0.4f, -0.4f);
            float fz = UnityEngine.Random.Range(-0.4f, -0.4f);
            clone.transform.position = new Vector3(fx, 4.0f, fz);
            clone.GetComponent <Renderer>().material.color = new Color(UnityEngine.Random.value, UnityEngine.Random.value, UnityEngine.Random.value);

            CardboardMagnetSensor.ResetClick();
        }
    }
Пример #6
0
    void Update()
    {
        if (CardboardMagnetSensor.CheckIfWasClicked() || Input.GetMouseButtonDown(0))
        {
            if (curScene == 0)
            {
                introManager.IsOnMagnet = true;
            }
            else if (curScene == 1)
            {
                gameManager.IsOnMagnet = true;
            }

            CardboardMagnetSensor.ResetClick();
        }
    }
Пример #7
0
    // Update is called once per frame
    void Update()
    {
        if (!magnetDetectionEnabled)
        {
            return;
        }

        if (CardboardMagnetSensor.CheckIfWasClicked())
        {
            Debug.Log("DO SOMETHING HERE");              // PERFORM ACTION.
            MachineGunController._instance.vrShootBullet();
            CardboardMagnetSensor.ResetClick();
        }

        if (Input.GetButtonDown("Fire1"))
        {
            MachineGunController._instance.vrShootBullet();
        }
    }
Пример #8
0
 // Update is called once per frame
 void Update()
 {
     if (!magnetDetectionEnabled)
     {
         return;
     }
     if (CardboardMagnetSensor.CheckIfWasClicked() || Input.GetMouseButtonDown(0))
     {
         if (!isStarted)
         {
             PlayGame();
         }
         else if (playerObj.canRestartGame())
         {
             RestartGame();
         }
         CardboardMagnetSensor.ResetClick();
     }
     if (playerObj.canRestartGame())
     {
         StopMonsters();
     }
 }