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()
    {
        
    }
}
相关推荐
小拉达不是臭老鼠6 小时前
Unity学习_ScriptableObject
学习·unity
Thomas_YXQ7 小时前
Unity无GC读取图片与网格完整方案
大数据·人工智能·unity·微信·产品运营
郝学胜-神的一滴11 小时前
中级OpenGL教程 008:精准控制高光光斑大小与强度
c++·unity·godot·three.js·图形学·opengl·unreal
avi911114 小时前
Unity 商业插件之(五)课外2 - Zenject的一些小Tips(学习备忘)
unity·游戏开发·团结引擎
元气少女小圆丶14 小时前
SenseGlove Nova 2+Unity开发笔记4
笔记·unity·游戏引擎
basketball61615 小时前
Go 语言从入门到进阶:6. 一文彻底吃透结构体(Struct)
开发语言·unity·golang
cheniie18 小时前
如何优化大景深场景光场渲染背景模糊问题
unity·光场渲染
拾忆丶夜1 天前
unity webgl 阴影条纹问题
unity·游戏引擎·webgl
tealcwu2 天前
【Unity实战】Unity IAP 4.x 在 Windows Store (UWP) 平台上的实现指南
windows·unity·游戏引擎
玉夏2 天前
【Shader基础】CG/HLSL 基础语法
unity·shader