10491人加入学习
(62人评价)
AR系列教程 - Vuforia入门 ( Unity 2017.3 )

制作完成于2018-01-16

价格 免费

private float touchTime;//记录长按的时间

private boll newTouch;

if(Input.GetMouseButton(0))//如果长按{
  Ray ray=Camera.main.ScreenPointToRay(InputmousePosition};
RaycastHit hitInfo;
if(PhysicsRaycasr(ray,out hitInfo)){
   if(Input.touchCount==1){
Touch touch=Input.GetTouch(0);
if(touch.phase==Began){newTouch=true;touchTime=Time.time;}
else if(touch.phase==TouchPhase.Stationary)//按住没有动
if(newTouch=true&&Time.time-touchTime>1f)//认为是长按
newTouch=false;
Destory(hitInfo.collider.gameObject);}
else{neTouch=false;}}

[展开全文]

1.要判断长按,需要定义一个变量来记录按的时间

private float touchTime;

2.定义一个变量,判断是不是新按上去的

private bool  newTouch=false;

 

 

3.在update里面编写功能。

//长按
                if (Input.touchCount == 1)
                {
                    Touch touch = Input.GetTouch(0);
                    if (touch.phase == TouchPhase.Began)
                    {
                        newTouch = true;
                        touchTime = Time.time;

 

                    }
                    else if (touch.phase == TouchPhase.Stationary)
                    {
                        if (newTouch == true && Time.time - touchTime > 1f)
                        {
                            newTouch = false;
                            Destroy(hitInfo.collider.gameObject);
                        }
                    }
                    else
                        newTouch = false;
                }

 

[展开全文]

TouchPhase.Stationaty//按住静止,没有动的意思

 

[展开全文]

授课教师

SIKI学院老师

课程特色

图文(1)
下载资料(1)
视频(24)

学员动态