簡體   English   中英

Unity3D中的觸摸和滑動問題

[英]Issue with Touch and slide in Unity3D

我有一款游戲,您可以在其中滑動一些東西,找到特別的東西。 除了滑動以外,您只需輕按它即可。 為此,我創建了以下代碼,但無法正常運行:

void Update()
 {
     if (Input.touchCount > 0)
     {
         // get the first one
         Touch firstTouch = Input.GetTouch(0);

         // if it began this frame
         if (firstTouch.phase == TouchPhase.Began)
         {
             if (firstTouch.position.x > screenCenter)
             {
                 Anim.SetBool("Swiper", true);
                 print("Swipe");
             }
         }
         else if (firstTouch.phase == TouchPhase.Stationary)
         {
             if (E.FInt == 1)
             {
                 //Sound
                 print("Debugged");
                 SceneManager.LoadScene(Beh.SceneArray[Beh.Counter]);
             }
         }
     }
 }

這里的問題是,即使您點擊,它也會執行滑動時的代碼。

讓我們看一下本節:

     // if it began this frame
     if (firstTouch.phase == TouchPhase.Began)
     {
         if (firstTouch.position.x > screenCenter)
         {
             Anim.SetBool("Swiper", true);
             print("Swipe");
         }
     }

如果觸摸階段Began並且觸摸位於屏幕的右側,則很明顯是輕掃。

不,不是。 這只是一個開始。 還沒有機會被刷過。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM