게임 개발 관련/Unity3D
[유니티] 안드로이드 폰에서 뒤로 가기 버튼 클릭했을 때...체크하기
sungho88
2018. 2. 24. 18:39
if(Application.platform == RuntimePlatform.Android)
{
if(Input.GetKey(KeyCode.Escape))
{
// Application.Quit();
}
}
위 코드는 update()에 넣는다.
이렇게 작성하면, 플랫폼이 안드로이드인지를 확인한 뒤에
뒤로가기 버튼은 키 코드로는 Escape이다.
따라서, 코드로 하면 KeyCode.Escape 이다.
이렇게하면, 안드로이드 폰이며 동시에 뒤로가기 버튼을 누른 조건에 해당된다.
// Application.Quit();
이 부분에 원하는 코드를 작성하면 된다.
최종 코드
void Update()
{
creditVal.text = credit.ToString(); // 숫자를 문자로
// stageVal.text = stage.ToString();
if (Application.platform == RuntimePlatform.Android)
{
if (Input.GetKey(KeyCode.Escape))
{
Back_Panel.SetActive(true);
}
}
}