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

 

相关文章:

  • 2021-11-23
  • 2022-12-23
  • 2021-10-17
  • 2021-11-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-13
猜你喜欢
  • 2021-10-20
  • 2021-12-11
  • 2022-12-23
  • 2021-12-04
  • 2021-12-19
  • 2021-11-28
  • 2021-08-31
相关资源
相似解决方案