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(URP渲染管线)的后处理、动画制作、虚拟相机(Virtual Camera)
开发语言·人工智能·计算机视觉·unity·c#·游戏引擎
MWHLS8 小时前
【以及好久没上号的闲聊】Unity记录8.1-地图-重构与优化
unity·开源
WarPigs19 小时前
Unity光照笔记
笔记·unity·游戏引擎
神码编程1 天前
【Unity】 HTFramework框架(六十五)ScrollList滚动数据列表
unity·游戏引擎·ugui
DanmF--1 天前
Protobuf工具
网络·unity·游戏引擎·游戏程序
敲代码的 蜡笔小新1 天前
【行为型之迭代器模式】游戏开发实战——Unity高效集合遍历与场景管理的架构精髓
unity·设计模式·c#·迭代器模式
敲代码的 蜡笔小新2 天前
【行为型之命令模式】游戏开发实战——Unity可撤销系统与高级输入管理的架构秘钥
unity·设计模式·架构·命令模式
驰愿2 天前
ET EntityRef EntityWeakRef 类分析
unity·et
敲代码的 蜡笔小新3 天前
【行为型之中介者模式】游戏开发实战——Unity复杂系统协调与通信架构的核心秘诀
unity·设计模式·c#·中介者模式
敲代码的 蜡笔小新3 天前
【行为型之解释器模式】游戏开发实战——Unity动态公式解析与脚本系统的架构奥秘
unity·设计模式·游戏引擎·解释器模式