您当前的位置: 首页 >  unity

unity工具人

暂无认证

  • 3浏览

    0关注

    205博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

unity Input.GetTouch

unity工具人 发布时间:2022-01-01 10:46:22 ,浏览量:3

触摸交互案例

Input.GetTouch(0).deltaPosition;//获取触摸滑动增量
float num = Input.GetTouch(0).deltaPosition.y * 0.003f;//使用y值增量例子

其他 单指点击


using UnityEngine;
using System.Collections;
 
public class touchTest: MonoBehaviour {	
	void Update() {
		int i = 0;
		while (i  0)
        {
            count += Input.touchCount;
        }
        if ((Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Moved)) //[color=Red]如果点击手指touch了  并且手指touch的状态为移动的[/color]
        {
            touchposition = Input.GetTouch(0).deltaPosition;  //[color=Red]获取手指touch最后一帧移动的xy轴距离[/color]
            //touchposition.x*0.01f, touchposition.y*0.01f//[color=Red]移动这个距离[/color]
        }
    }
    void OnGUI()
    {
        GUI.Label(new Rect(10, 10, 100, 30), "cishu:" + count.ToString());
        GUI.Label(new Rect(10, 50, 100, 30), touchposition.ToString());
    }
}

官方文档 相关api 在这里插入图片描述 在这里插入图片描述

关注
打赏
1656671177
查看更多评论
立即登录/注册

微信扫码登录

0.0522s