赞
踩
应分为两种情况:
UnityEditor.EditorApplication.isPlaying = false;
Application.Quit();
完整代码如下:
#if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false;
#else
Application.Quit();
#endif
实际用例代码如下:
using UnityEngine; using UnityEngine.SceneManagement; public class GameMenu : MonoBehaviour { public void OnStartGame() { SceneManager.LoadScene(1); } public void OnExitGame() { #if UNITY_EDITOR UnityEditor.EditorApplication.isPlaying = false; #else Application.Quit(); #endif } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。