我已经实现了将它编译成Windows或Mac,但是没有运气的WebGL。
请参阅我的专栏
从Windows到Windows(将它们放在.bat文件中)
set mypath=%cd%
@echo %mypath%
"C:\Program Files\Unity\Editor\Unity.exe" -quit -batchmode -logFile stdout.log -projectPath %mypath% -buildWindowsPlayer "builds\mygame.exe"
从Linux到Windows(将它们放在.sh文件中)
#/bin/bash
projectPath=`pwd`
xvfb-run --auto-servernum --server-args='-screen 0 1024x768x24:32' /opt/Unity/Editor/Unity -batchmode -nographics -logfile stdout.log -force-opengl -quit -projectPath ${projectPath} -buildWindowsPlayer "builds/mygame.exe"
从Windows或Linux到Mac:将 -buildWindowsPlayer 替换为 -buildOSXPlayer ,将 mygame.exe 替换为 mygame.app
但是,我遇到了WebGL的麻烦。 Unity3D的文档:https://docs.unity3d.com/Manual/CommandLineArguments.html 不提供任何帮助
有命令参数
-buildTarget webgl
但没有任何反应。
HEEEEEEEELLLLLLLLLLLLLPPPPPPP !!!! :(
答案 0 :(得分:3)
我找到了它
制作文件夹资产/编辑
并放置cs脚本
using UnityEditor;
class WebGLBuilder {
static void build() {
// Place all your scenes here
string[] scenes = {"Assets/scenes/S_MainMenu.unity",
"Assets/scenes/S_Login.unity",
"Assets/scenes/S_Help.unity",
"Assets/scenes/S_1.unity",
"Assets/scenes/S_Reward.unity",
"Assets/scenes/S_Credits.unity",
"Assets/scenes/S_Settings.unity",
"Assets/scenes/S_SceneSelector.unity"};
string pathToDeploy = "builds/WebGLversion/";
BuildPipeline.BuildPlayer(scenes, pathToDeploy, BuildTarget.WebGL, BuildOptions.None);
}
}
您已准备好使用以下bat文件从命令行进行编译:
set mypath=%cd%
@echo %mypath%
"C:\Program Files\Unity\Editor\Unity.exe" -quit -batchmode -logFile
stdout.log -projectPath %mypath% -executeMethod WebGLBuilder.build
即。 WebGLBuilder成为命令行中可用的参数。