How to Unity3d : command build without build pipeline

unity-logoThis tuturial explains how to build application without using the pro edition of Unity3d editor, wich integrates buildpipeline functionalities. Simply by using command line script.

Warning : This tutorial is not useful if you own the Pro Edition of Unity3d, wich already contains a buildpipeline system using Unity3d scriptting (Javascript or CSharp). In this case, go see :

http://docs.unity3d.com/Manual/BuildPlayerPipeline.html

Step 1 : Create Project

So create a new project.

ScreenShot003

ScreenShot001

Save your project !

ScreenShot003

Step 2 : Close Unity3d !

This an important step because Unity3d only allows a single running instance of Unity3d.

ScreenShot004

Step 2 : Create Script

Create a new file named build.bat at the project root folder, next to Assets folder.

ScreenShot002

build.bat

"C:\Program Files\Unity\Editor\Unity.exe" -quit -batchmode  -logFile stdout.log -buildWindowsPlayer "builds\build.exe"

Details :

execute unity3d in batchmode / command line :

"C:\Program Files\Unity\Editor\Unity.exe" -quit -batchmode

create a log file containning build console output :

-logFile stdout.log

build the gameproject for windows plateforme :

-buildWindowsPlayer "builds\build.exe"

Demo

Launch build.bat via command line for console output result, or just click on build.bat.

ScreenShot002

A new window pops.

ScreenShot005

After a while (30 sec), the window closes itself. The build is finished !

Go open the newly created build folder.

ScreenShot006

It contains your game executable.

Click on build.exe

ScreenShot007

The game launcher appears. Click on Play!

ScreenShot008

Then your game launchs.

ScreenShot011

ScreenShot010

(it’s an empty scene here)

Build console output is in stdout.log file, next to build.bat file.

ScreenShot012

ScreenShot013

Error (first use only)

Unity3d needs to link your project folder.

Then you need to open your project with Unity3d a first time before building it by command line. For duplicate or moved project folder, you’ll need to reopen the folder with unity3d.

Conclusion

This approach is more developper friendly than the unity3d IDE. You can use your own text editor like SublimeText and build with an automatic task.

Unity3d web site is poorly documented on this usage.

Sources

https://github.com/DamienFremont/blog/tree/master/20150625-unity3d-build_command

References

http://docs.unity3d.com/Manual/CommandLineArguments.html

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s