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()
    {
        
    }
}
相关推荐
淡海水3 小时前
【节点】[EyeSurfaceTypeDebug节点]原理解析与实际应用
unity·游戏引擎·debug·shadergraph·图形·surface·eye
淡海水8 小时前
【节点】[IrisLimbalRing节点]原理解析与实际应用
unity·游戏引擎·iris·shadergraph·图形·ring·limbal
在路上看风景10 小时前
33. RenderTarget
unity
在路上看风景11 小时前
34. GPU偏爱2的幂次
unity
Zik----11 小时前
Unity的基础使用
unity·游戏引擎
在路上看风景1 天前
1.11 资源划分策略
unity
红黑色的圣西罗1 天前
Unity减少Draw和SetPassCall的手段简述
unity·游戏引擎
淡海水1 天前
【节点】[CorneaRefraction节点]原理解析与实际应用
unity·游戏引擎·shadergraph·图形·cornea·refraction
小贺儿开发1 天前
《唐朝诡事录之西行》——降魔变
科技·unity·人机交互·创意·文旅·hdrp
泡泡茶壶ᐇ1 天前
Unity游戏开发入门指南:从零开始理解游戏引擎核心概念(二:Unity游戏开发的本质:从可视化编程到面向对象的顿悟)
unity·游戏引擎