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()
    {
        
    }
}
相关推荐
天人合一peng3 小时前
Unity中button 和toggle监听事件函数有无参数
前端·unity·游戏引擎
_乐无4 小时前
Unity加载gly 点云 高斯泼溅渲染
unity
坚定信念,勇往无前5 小时前
unity发布BuildWebGL.wasm 加载过慢
unity·wasm
avi91119 小时前
Unity Data Excel读取方法+踩坑记;和WPS Excel的一些命令
unity·游戏引擎·excel·wps·data
天人合一peng10 小时前
Unity 中Canvas 或image打勾时不显示
unity
淡海水1 天前
【节点】[Houndstooth节点]原理解析与实际应用
unity·游戏引擎·shadergraph·图形·houndstooth
微:xsooop2 天前
iOS上架被拒4.3(a) 10次到过审历程
flutter·unity·ios·uniapp
jtymyxmz2 天前
《Unity Shader》14.1 卡通风格的渲染
unity·游戏引擎
天人合一peng3 天前
unity获得和修改button的text(TMP)
java·前端·unity
dzj20213 天前
Unity中使用LLMUnity遇到的问题(三)——如何配置和使用知识库
unity·llmunity·知识库大模型