UGUI Button 退出应用或退出编辑器当前运行状态

代码退出当前编辑器运行状态测试正常。

Unity3d引擎版本:Uinty3d 20233.2.3f1

脚本代码:

cs 复制代码
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class btnCloseScript : MonoBehaviour,IPointerClickHandler
{
    public void OnPointerClick(PointerEventData eventData)
    {

        #if UNITY_EDITOR
        UnityEditor.EditorApplication.isPlaying = false;
        #else
        Application.Quit();
        #endif

        //Application.Quit();
        Debug.Log("Quit");
    }

    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}
相关推荐
心之所向,自强不息5 小时前
【Unity Shader编程】之让画面动起来
unity·游戏引擎
不伤欣1 天前
游戏设计模式 - 子类沙箱
游戏·unity·设计模式
快乐觉主吖1 天前
Unity的日志管理类
android·unity·游戏引擎
WarPigs2 天前
Unity性能优化笔记
笔记·unity·游戏引擎
T.D.C2 天前
【业务框架】3C-相机-Cinemachine
unity
Clank的游戏栈2 天前
Unity基于GraphView的可视化关卡编辑器开发指南
unity·编辑器·游戏引擎
海尔辛3 天前
Unity UI 性能优化--Sprite 篇
ui·unity·性能优化
XR-AI-JK3 天前
Unity VR/MR开发-VR设备与适用场景分析
unity·vr·mr
ChiLi_Lin3 天前
Unity异常上报飞书工具
unity·游戏引擎·飞书
地狱为王4 天前
基于VLC的Unity视频播放器(四)
unity·游戏引擎·音视频