Unity3D BuildPipeline.BuildPlayer打包后没有.exe文件
最近在使用代码进行打包,打包成功了,却没有没有可执行文件。
官方代码如下
BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions();
buildPlayerOptions.scenes = new[] { "Assets/Scene1.unity", "Assets/Scene2.unity" };
buildPlayerOptions.locationPathName = "iOSBuild";
buildPlayerOptions.target = BuildTarget.iOS;
buildPlayerOptions.options = BuildOptions.None;
BuildReport report = BuildPipeline.BuildPlayer(buildPlayerOptions);
我是需要打包到Window PC端,所以只是修改了打包平台属性以及路径
BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions(); ;
buildPlayerOptions.scenes = new string[] { "Assets/Scenes/UI/UseUIMask.unity" };
buildPlayerOptions.target = BuildTarget.StandaloneWindows;
buildPlayerOptions.locationPathName = $"../Build/AutoBuild/PC/{DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss")}";
buildPlayerOptions.targetGroup = BuildTargetGroup.Standalone;
buildPlayerOptions.options = BuildOptions.None;
var report = BuildPipeline.BuildPlayer(buildPlayerOptions);
经过以下操作均为解决:
- 重启Unity
- 修改打包文件的输出路径
最后一个没有扩展名的文件引起了我的注意
将其加上扩展名.exe
就可以运行了。
看来我是汉语没学好吗???这明明是路径啊,按我理解就是不加扩展名的!
buildPlayerOptions.locationPathName = $"../Build/AutoBuild/PC/{DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss")}";
对于PC端来说,路径原来是要加扩展名的!!!
标签:Unity3D,exe,BuildPlayer,PC,buildPlayerOptions,BuildPipeline,new,打包 From: https://www.cnblogs.com/NZQLA/p/16911946.html