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

查看:23
本文介绍了如何在 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天全站免登陆