Multi Touch Input

Revisado con versión: 4.3

-

Dificultad: Principiante

Modern mobile devices have screen that can receive accurate multitouch inputs from the user. In this video you will learn how to access these touches from the Input class.

Multi Touch Input

Principiante Mobile & Touch

TouchTest

Code snippet

using UnityEngine;
using System.Collections;

public class TouchTest : MonoBehaviour 
{
    void Update () 
    {
        Touch myTouch = Input.GetTouch(0);

        Touch[] myTouches = Input.touches;
        for(int i = 0; i < Input.touchCount; i++)
        {
            //Do something with the touches
        }
    }
}
#pragma strict

function Update () 
{
    var myTouch : Touch = Input.GetTouch(0);

    var myTouches = Input.touches;
    for(var i = 0; i < Input.touchCount; i++)
    {
        //Do something with the touches
    }
}
import UnityEngine
import System.Collections


public class TouchTest(MonoBehaviour):

    private def Update():
        myTouch as Touch = Input.GetTouch(0)
        
        myTouches as (Touch) = Input.touches
        for i in range(0, Input.touchCount):
            pass
        //Do something with the touches

Documentación relacionada