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()
    {
        
    }
}
相关推荐
绀目澄清2 小时前
unity3d AI Navigation 中文文档
游戏·unity
绀目澄清4 小时前
Unity 的AI Navigation 系统详细总结
人工智能·unity·游戏引擎
绀目澄清6 小时前
Unity3D AI Navigation 详解:从基础概念到实战应用
unity·游戏引擎
绀目澄清7 小时前
Unity3D AI导航系统完全指南:从核心概念到动画耦合
人工智能·unity
__water7 小时前
RHK《模型贴图自由更换位置》
unity·贴图·模型贴图·移动不丢失
JIes__7 小时前
Unity(二)——3D数学
unity·游戏引擎
淡海水7 小时前
【节点】[RandomRange节点]原理解析与实际应用
unity·游戏引擎·shadergraph·图形·randomrange
weixin_424294671 天前
在Unity中,摄像机移动时出现“残影”或“闪烁”是常见问题,主要原因和处理方法。
unity·游戏引擎
天人合一peng1 天前
unity 3d 通过游戏对象的名子查到其对象
游戏·unity·游戏引擎
纯属个人爱好1 天前
Unity2020+PicoNeo3Pro开发
unity·vr