Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

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:
    31,377
    cultzone likes this.
  3. cultzone

    cultzone

    Joined:
    Oct 20, 2019
    Posts:
    39