Auto build as soon as Unity is started


1. create "MyEditorScript.cs" in ".. /Assets/Editor/"
using UnityEditor;
class MyEditorScript
{
     static void MyMethod ()
     {
         string[] scenes = { "Assets/hot.unity" };
         BuildPipeline.BuildPlayer(scenes,"WebPlayer.unity3d",BuildTarget.WebPlayerStreamed,BuildOptions.None);
     }
}
 
2. run command:
C:\Program Files\Unity\Editor\Unity.exe -quit -batchmode -executeMethod MyEditorScript.MyMethod


additionals:
1. -executeMethod <ClassName.MethodName>
Execute the static method as soon as Unity is started, the project is open and after the optional asset server update 
has been performed. This can be used to do continous integration, perform Unit Tests, make builds, prepare some data, etc.
2. command line scripts can't base on UI to be present as it won't be.

猜你喜欢

转载自blog.csdn.net/kong5461/article/details/22724455