Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Jagwire · Nov 11, 2014 at 10:46 PM · buildbuildpipelinecommand-line

Command line flag to build WebGL

The manual outlines command line options here: http://docs.unity3d.com/Manual/CommandLineArguments.html but there is no mention of building a WebGL project. Has anyone found a flag to do such with the Unity 5 Beta?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by joonturbo · May 26, 2015 at 12:20 PM

Unity 5.0.1 has `BuildTarget.WebGL`

 //place this script in the Editor folder within Assets.
 using UnityEditor;
  
  
 //to be used on the command line:
 //$ Unity -quit -batchmode -executeMethod WebGLBuilder.build
  
 class WebGLBuilder {
     static void build() {
         string[] scenes = {"Assets/main.unity"};
         BuildPipeline.BuildPlayer(scenes, "WebGL-Dist", BuildTarget.WebGL, BuildOptions.None);
     }
 }

(from https://gist.github.com/jagwire/0129d50778c8b4462b68)

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Jagwire · May 26, 2015 at 01:04 PM 1
Share

Ironic that I forgot to update this answer myself with my own gist :)

avatar image
0

Answer by Graham-Dunnett · Nov 11, 2014 at 10:47 PM

There's not a flag for this yet.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Jagwire · Nov 12, 2014 at 03:04 PM 0
Share

Are there any plans to develop one?

avatar image joonturbo · May 26, 2015 at 12:20 PM 0
Share

5.0.1 has BuildTarget.WebGL. I'm currently looking to see if you can set Optimization level (slow-fast-fastest) somehow

avatar image joonturbo · May 26, 2015 at 01:23 PM 0
Share

I figured out that the following is possible, but not sure if it works (since these things aren't exactly verbose)

 static void PerformBuildWebGLSlow()
     {
         **EditorUserBuildSettings.webGLOptimizationLevel = 2;**
         BuildPipeline.BuildPlayer(GetScenes(), "Bin/webgl/", BuildTarget.WebGL, BuildOptions.None);
     }
avatar image
0

Answer by unity_sxF4kWUhnH3bzw · Jul 13, 2018 at 01:37 PM

Here is a Programmer to English translation of the answers in this thread:

There is currently no command line argument to build a WebGL player. To work around this, you can use the command line argument to run a c# script. You can create a c# script that makes calls to Unity to do the building, and then run that script from the command line.

Here is the script to make. It goes in the Assets/Editor folder of your project.

  using UnityEditor;
   
  class WebGLBuilder {
      static void build() {
          string[] scenes = {"Assets/main.unity"};
          BuildPipeline.BuildPlayer(scenes, "WebGL-Dist", BuildTarget.WebGL, BuildOptions.None);
      }
  }

Then use the command line option to call the code in the c# script:

 Unity.exe -quit -batchmode -executeMethod WebGLBuilder.build

Specifically, note the -executeMethod command line argument, which lets you call a method in a c# class in the project.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Distribute terrain in zones 3 Answers

ArgumentException: targetGroup must be valid 1 Answer

xr plugin managment arkit required script 0 Answers

Build hang on compiling scripts in Unity 2018.2 2 Answers

Pink objects with -batchmode -nographics 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges