When multi-touch, the subscript is starting from 0, two touch points subscript is 0, 1.
The code is as follows:
NT Touchcount = 2; Number of touch frames if (Touchcount = = Input.touchcount ())
{Vector2 TouchPosition1 = Input.gettouch (0). Position;vector2 touchPosition2 = Input.gettouch (1). Position;}
1.input.touchcount touch grows with 50 increments in one second.
2.input.gettouch (0). phase==touchphase.moved the state of the last frame slide in the finger slide is moving.
Several states of 3.TouchPhase touch.
4.touch.deltaposition Increment position (Input.gettouch (0). deltaposition) The value of the last frame slide, returning only the XY axis coordinates, also available Vector3 (z-axis 0), so generally with vector2 receive.
Static var aa:int; function Update () {if(input.touchcount>0) {print ( Input.touchcount);}} function Ongui () {GUI. Label (Rect, thesdff , the );}
Touchcount refers to the number of touch frames. Note that the touch event can only be run on the emulator or on the real machine (tested pass), about a second touch. Touchcount+50 times or so. 2.input.touches Touch list.
//Prints number of fingers touching the screen//output Touch the number of fingers on the screenfunction Update () {varFingercount =0; for(varTouch:touchinchinput.touches) {if(Touch.phase! = touchphase.ended && Touch.phase! =touchphase.canceled) Fingercount++;}if(Fingercount >0) Print ("User has"+ Fingercount +"Finger (s) touching the screen");}
3. Let cube move the code with touch:
Static varCountint;//define the number of TouchcountvarParticle_:gameobject;//defines the cube object to be storedvarTouchposition:vector3;//Store moving three-dimensional coordinate valuesfunction Update () {if(input.touchcount>0) {Count+=Input.touchcount;}if((input.touchcount>0&&input.gettouch (0). phase==touchphase.moved))//[color=red] If the finger touch is clicked and the state of the finger touch is moving [/color]{touchposition=input.gettouch (0). Deltaposition;//[color=red] gets the XY axis distance of the last frame movement of the finger Touch [/color]Particle_.transform. Translate (touchposition.x*0.01, touchposition.y*0.01,0);//[color=red] Move this distance [/color]}}function Ongui () {GUI. Label (Rect (Ten,Ten, -, -),"Cishu:"+count. ToString ()); Gui. Label (Rect (Ten, -, -, -), Touchposition. ToString ());}
Reference from: http://www.unitymanual.com/2775.html
Unity3d realizes two-finger touch and input-type touch in mobile phones