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()
    {
        
    }
}
相关推荐
jtymyxmz4 小时前
《Unity Shader》12.5 Bloom 效果
unity·游戏引擎
jtymyxmz6 小时前
《Unity Shader》12.6 运动模糊
unity·游戏引擎
jtymyxmz9 小时前
《Unity Shader》12.4.2 实现
unity·游戏引擎
sindyra11 小时前
Unity UGUI 之 Canvas Scaler
unity·游戏引擎
在路上看风景15 小时前
2.Square Grid
unity
程序猿阿伟15 小时前
《突破Unity热更新瓶颈:底层函数调用限制与生态适配秘籍》
unity·游戏引擎
在路上看风景17 小时前
13. UGUI合批
unity
jtymyxmz1 天前
《Unity Shader》12.2调整屏幕的亮度、饱和度和对比度
unity·游戏引擎
AllBlue2 天前
unity嵌入安卓界面,如何显示状态
android·unity·游戏引擎
tealcwu2 天前
【Unity技巧】实现在Play时自动保存当前场景
java·unity·游戏引擎