Unity:You must exit play mode to save the scene运行状态下编辑的内容无法保存问题

3 篇文章 0 订阅

Unity 有时候编辑的内容保存时提示如下信息:You must exit play mode to save the scene。

这是因为手动点暂停游戏后,画面状态并没有被关闭,而导致无法保存刚刚编辑的内容。

解决方案:

1.SampleScence下创建一个空白物体 Create empty。命名随意,比如esc4exit

2.为此空白物体创建一个脚本: add component->new script

3.代码块:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class exit : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        //运行时按下esc,退出
        if(Input.GetKey(KeyCode.Escape))
        {
            //先结束运行状态
            UnityEditor.EditorApplication.isPlaying = false;
            //再退出应用
            Application.Quit();
        }
    }
}

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值