添加ESC脚本
使用Unity打包发布的过程中,考虑到打开的程序会处于全屏界面,而此时我们又会有退出全屏的需求,因此需要添加ESC脚本,当我们单击ESC脚本的过程中,退出全屏模式。
 在Assets/Scenes下,创建esc.cs脚本,脚本内容如下:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class esc : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        
    }
    // Update is called once per frame
    void Update()
    {
        if(Input.GetKey(KeyCode.Escape))
        {
            Screen.fullScreen = false; // 单击按钮ESC退出全屏
        }
        
    }
}
添加完成后,可将esc.cs脚本改在到任意控件下。
打包发布
1、单击File->build settings,单击Add Open Scenes,添加目标Scene,然后单击Player Setting。
 
 2、修改公司名称、产品名称、版本号等基础信息,并设置软件的初始全屏模式。
 
 3、关掉上述窗口,单击下图中的Build按钮,选择相应的文件夹,进行发布即可。
 
 4、至此,即可在目标文件中查看生成的目标exe后缀文件,运行即可。



















