// Update is called once per frame
    void Update()
    {
        buttonRect = TouchControlsManager.RectTransformToScreenSpace(rectTransform);

        for (int i = 0; i < Input.touchCount; ++i)
        {
            Touch t = Input.touches[i];

            if (buttonRect.Contains(t.position))
            {
                Vector2 anchor = new Vector2(t.position.x / Screen.width, t.position.y / Screen.height);
                positioner.PositionControls(anchor);

                if (t.phase == TouchPhase.Ended)
                {
                    positioner.StorePosition(anchor);
                }

                break;
            }
        }

#if UNITY_EDITOR
        Vector2 m = Input.mousePosition;
        if (buttonRect.Contains(m) && Input.GetButton("Fire1"))
        {
            Vector2 anchor = new Vector2(m.x / (float)Screen.width, m.y / (float)Screen.height);
            Debug.Log(anchor);
            positioner.PositionControls(anchor);
        }
#endif
    }
Exemple #2
0
    private void Start()
    {
        player = ReInput.players.GetPlayer(0);
        ReInput.InputSourceUpdateEvent += OnInputUpdate; // subscribe to input update event
        controller = (CustomController)player.controllers.GetControllerWithTag(ControllerType.Custom, "Touch");

        buttonRect = TouchControlsManager.RectTransformToScreenSpace(rectTransform);
    }
    // Start is called before the first frame update
    void Start()
    {
        manager       = TouchControlsManager.touchControls;
        lookRect      = TouchControlsManager.RectTransformToScreenSpace(lookRectTransform);
        dpiMultiplier = Screen.dpi / standardPPI;

#if UNITY_IOS
        dpiMultiplier *= 50;
#endif
    }
Exemple #4
0
 // Start is called before the first frame update
 void Start()
 {
     manager  = TouchControlsManager.touchControls;
     moveRect = TouchControlsManager.RectTransformToScreenSpace(moveRectTransform);
 }