[Unity3D]如何实现点击按钮退出游戏 1using System;
2using System.Collections;
3using System.Collections.Generic;
4using UnityEngine;
5using UnityEngine.UI;
421事件内容
6
7public class ExitGame : MonoBehaviour
8 {
9private void  Start() {
       /*查按钮组件并添加事件(点击事件)*/
10this.GetComponent<Button>().onClick.AddListener(OnClick);
11    }
12
13/*点击时触发*/
14private void OnClick() {
15/*将状态设置false才能退出游戏*/
16        UnityEditor.EditorApplication.isPlaying = false;
17        Application.Quit();
18    }
19
20
21 }