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 小时前
Blender:法线图&黑白图
游戏·unity·游戏引擎·blender·笔记分享
HahaGiver6665 小时前
从0到1做一个“字母拼词”Unity小游戏(含源码/GIF)- 实现多单词顺序通关进度逻辑
unity·游戏引擎·游戏程序
Dr.勿忘10 小时前
Unity一分钟思路---UI任务条:宝箱位置如何准确卡在百分比位置上
ui·unity·游戏程序·屏幕适配
weixin_4242946710 小时前
Unity 实现 ScrollBar 值变化控制 Panel 位置的方法
unity·游戏引擎
在路上看风景1 天前
## 2.2 状态同步
unity
霜绛1 天前
Unity:lua热更新(一)——AB包AssetBundle、Lua语法
笔记·学习·游戏·unity·lua
霜绛1 天前
Unity:lua热更新(二)——Lua语法(续)
笔记·学习·unity·游戏引擎·lua
yi碗汤园1 天前
【一文了解】C#反射
开发语言·unity·c#
HahaGiver6661 天前
Unity Shader Graph 3D 实例 - 基础的模型贴图渲染
3d·unity·游戏程序·贴图·游戏美术
HahaGiver6661 天前
Unity Shader Graph 3D 实例 - 一个简单的3D打印效果
3d·unity·游戏引擎