[英]Back button is not working propely, why?
我在Canvas中有dx類。 它無法正常工作。 當我處於“ 購買”狀態並單擊“后退”按鈕時,我將進入MainMenu 。 我要進入MainMarket而不是MainMenu,該如何解決?
public class dx : MonoBehaviour {
public GameObject MainMenu;
public GameObject Login;
public GameObject MainMarket;
public GameObject Bought;
void Update()
{
if (Login.activeSelf == true && Input.GetKey(KeyCode.Escape))
{
MainMenu.SetActive(true);
Login.SetActive(false);
Debug.Log("Login");
return;
}
else if (MainMarket.activeSelf == true && Input.GetKey(KeyCode.Escape))
{
MainMenu.SetActive(true);
MainMarket.SetActive(false);
Debug.Log("MainMenu");
return;
}
else if (Bought.activeSelf == true && Input.GetKey(KeyCode.Escape))
{
MainMarket.SetActive(true);
Bought.SetActive(false);
Debug.Log("Bought");
return;
}
}
}
只要按下鍵,Input.GetKey就會返回true。 而是使用Input.GetKeyDown,它僅在按下按鈕的第一幀返回true。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.