Example #1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0) && !EventSystem.current.IsPointerOverGameObject())
        {
            Vector3    point = new Vector3(_camera.pixelWidth / 2, _camera.pixelHeight / 2, 0);
            Ray        ray   = _camera.ScreenPointToRay(point);
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit))
            {
                GameObject     hitObject = hit.transform.gameObject;
                ReactiveTarget target    = hitObject.GetComponent <ReactiveTarget>();
                if (target != null)
                {
                    target.ReactiveToHit();
                    Messenger.Broadcast(GameEvent.ENEMY_HIT);
                }
                else
                {
                    StartCoroutine(SphereIndicator(hit.point));
                }
            }
        }

        if (Input.GetMouseButtonDown(1) && !popup.activeSelf)
        {
            OnGUI();
            hide = !hide;
        }
    }