2017-07-13 55 views
1

我已经实现将它编译到Windows或Mac中,但没有使用WebGL。如何从命令行编译Unity3D游戏项目到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-buildOSXPlayermygame.exemygame.app

但是,我有WebGL的麻烦。 Unity3D的文档:https://docs.unity3d.com/Manual/CommandLineArguments.html 不提供任何帮助

有命令参数 -buildTarget WebGL的
但没有与这种情况发生。

HEEEEEEEELLLLLLLLLLLLLPPPPPPP !!!! :(

回答

1

好吧,我发现它

使文件夹资产/编辑

并把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成为可用的参数m命令行。

+0

为了监控Unity.exe过程,你可以在PHP中使用:对于Windows服务器:下面的PHP命令生成CSV格式的报告,其统一进程在服务器上运行。 $ processUnityCSV = exec('TASKLIST/FI“imagename eq Unity.exe”/ v/fo CSV'); – jimver04

相关问题