Beispiel #1
0
    void Update()
    {
#if UNITY_EDITOR
        //Works For devices with mouse
        if (Input.GetMouseButton(0))
        {
            // Check if the mouse was clicked over a UI element
            if (EventSystem.current.IsPointerOverGameObject())
            {
                return;
            }
        }
#endif

#if UNITY_ANDROID
        //works for devices with touch
        if (Input.touchCount > 0)
        {
            if (Input.GetTouch(0).phase == TouchPhase.Began || Input.GetTouch(0).phase == TouchPhase.Moved || Input.GetTouch(0).phase == TouchPhase.Stationary)
            {
                // Check if finger is over a UI element
                if (EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId))
                {
                    return;
                }
            }
        }
#endif

#if UNITY_IOS
        if (Input.touchCount > 0)
        {
            if (Input.GetTouch(0).phase == TouchPhase.Began || Input.GetTouch(0).phase == TouchPhase.Moved || Input.GetTouch(0).phase == TouchPhase.Stationary)
            {
                // Check if finger is over a UI element
                if (EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId))
                {
                    return;
                }
            }
        }
#endif
        //Auto-Fires $fireRate/seconds$ bullets while touching screen
        if (Input.GetKey(KeyCode.Mouse0) && Time.time - lastShot > 1 / fireRate && throwing && allowedFromSuperball)
        {
            lastShot = Time.time;
            ThrowBullet();
        }
        if (Input.GetKeyDown(KeyCode.Mouse0))
        {
            ui.ActivateMainUi(true);

            ui.FillPowerupBar(true);
        }
        if (Input.GetKeyUp(KeyCode.Mouse0))
        {
            ui.FillPowerupBar(false);
        }
    }