Search Unity

Feature Request Mobile Detect Device Screen

Discussion in 'Scripting' started by cultzone, Sep 8, 2020.

  1. cultzone

    cultzone

    Joined:
    Oct 20, 2019
    Posts:
    39
    Hi everyone!

    We re back to ask another trick to make detection on mobile device to let window screen so mor confortable to user:

    void Update()
    {
    if (Pressed)
    {
    if (PointerId >= 0 && PointerId < Input.touches.Length)
    {
    TouchDist = Input.touches[PointerId].position - PointerOld;
    PointerOld = Input.touches[PointerId].position;
    }
    else
    {
    TouchDist = new Vector2(Input.mousePosition.x, Input.mousePosition.y) - PointerOld;
    PointerOld = Input.mousePosition;
    }
    }
    else
    {
    TouchDist = new Vector2();
    }
    }
     
    Last edited: Sep 15, 2020
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,697
    cultzone likes this.
  3. cultzone

    cultzone

    Joined:
    Oct 20, 2019
    Posts:
    39