如何为Android应用程序统一访问手机后退按钮 [英] How to access mobiles back button in unity for android applications

查看:89
本文介绍了如何为Android应用程序统一访问手机后退按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建带有菜单场景和许多其他场景的VR应用程序..当用户按下手机后退按钮(android)时,我想从任何其他场景回到菜单场景.什么是脚本为此,我应该在哪里放置脚本?

I am building a VR application with a menu scene and many other scenes.. I would like to get back into the menu scene from any other scene when the user hits the mobiles back button (android).. What is the script for that and where should i place the script??

推荐答案

您可以使用Escape键盘代码来检测Android上的后退按钮.

You use the Escape keycode to detect back button press on Android.

using UnityEngine.SceneManagement;

void Update()
{
    if (Input.GetKey(KeyCode.Escape))
    {
        SceneManager.LoadScene("Main Menu");
    }
}

这篇关于如何为Android应用程序统一访问手机后退按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆