gpt4 book ai didi

unity3d - touch.phase == TouchPhase.Canceled 无效

转载 作者:行者123 更新时间:2023-12-05 07:58:18 25 4
gpt4 key购买 nike

我厌倦了处理和解决与多点触控相关的问题。我同时使用最多 5 次触摸,但是当两个对象上有两个触摸并且我移动手指时,两个触摸都触发了 TouchPhase.Ended 事件,但没有触发 TouchedPhase.Canceled .

我想在我的手指离开这些对象时触发 TouchPhase.Canceled

if (touch.phase == TouchPhase.Began) { 
hitObject.GetComponent ().TouchDown (hitObject);
}

if (touch.phase == TouchPhase.Ended) {
hitObject.GetComponent ().TouchExit (hitObject);
}

if (touch.phase == TouchPhase.Moved || touch.phase == TouchPhase.Stationary) {
hitObject.GetComponent ().TouchStay (hitObject);
}

if (touch.phase == TouchPhase.Canceled) {
print ("Touched canceled....");
hitObject.GetComponent ().TouchExit (hitObject);
}

最佳答案

如果我正确理解你的评论

Look,I have one object on my screen.I use raycast for detecting that object.in hitObject i m stored that hittedObject and when my fingure touchdown on that object then it works. if i touchup my fingure from that hitted object that is also worked.when my fingure is stayed on that object or i m move my fingure on that hitted object that is also worked. but when during moving my fingure if it is move outside that object at that time TouchPhase.Canceled event should be fired. but that can not worked . That is my issue. How can i solved it ?

I want to stop dragging/swapping finger (not moving) on that hitted object how can i do?

您将不得不根据触摸位置限制滑动。

var realWorldPos = Camera.main.ScreenToWorldPoint(touch.position);

if(realWorldPos.x < maximumXSwipePosition && realWorldPos.x > minimumXSwipePosition)
{
//do the stuff you want to do
}
//otherwise, don't do it.

关于unity3d - touch.phase == TouchPhase.Canceled 无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25218525/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com