示例#1
0
        void OnUpdate()
        {
            //Debug.Log("Update");

            if (mProcess == null)
            {
                EditorApplication.update -= OnUpdate;
                mEmpty = true;
            }


            try {
                mProcess.MoveNext();
            } catch (Exception e) {
                Debug.LogException(e);
                EditorApplication.update -= OnUpdate;
                return;
            }

            if (mProcess != null && !mProcess.IsDone)
            {
                Repaint();
                Focus();
            }
        }
示例#2
0
        /// <summary>
        /// Builds a given build collection from command line. Call this method directly from the command line using Unity in headless mode.
        /// <https://docs.unity3d.com/Documentation/Manual/CommandLineArguments.html>
        ///
        /// Provide `collection` parameter to your command line build to specify the collection you want to build.
        /// All selected build processes within the collection will be build.
        ///
        /// Example: -collection=Assets/New\ BuildCollection.asset
        /// </summary>
        public static void BuildFromCommandLine()
        {
            bool batchMode = false;

            string[] arguments      = System.Environment.GetCommandLineArgs();
            string[] availableArgs  = { "-batchmode", "-collection=", "-android-sdk=", "-buildTag=", "-buildAll", "-commitID=", "-tagName=" };
            string   collectionPath = "";
            string   androidSdkPath = "";
            string   buildTag       = "";
            string   commitID       = "";
            string   tagName        = "";
            bool     buildAll       = false;

            foreach (var s in arguments)
            {
                if (s.StartsWith("-batchmode"))
                {
                    batchMode = true;
                    Debug.Log("UBS process started in batchmode!");
                }

                if (s.StartsWith("-collection="))
                {
                    collectionPath = s.Substring(availableArgs[1].Length);
                }

                if (s.StartsWith("-android-sdk="))
                {
                    androidSdkPath = s.Substring(availableArgs[2].Length);
                }

                if (s.StartsWith("-buildTag="))
                {
                    buildTag = s.Substring(availableArgs[3].Length);
                }

                if (s.StartsWith("-buildAll"))
                {
                    buildAll = true;
                    Debug.Log("Selection override: building whole collection!");
                }

                if (s.StartsWith("-commitID="))
                {
                    commitID = s.Substring(availableArgs[5].Length);
                }

                if (s.StartsWith("-tagName="))
                {
                    tagName = s.Substring(availableArgs[6].Length);
                }
            }
            if (collectionPath == null)
            {
                Debug.LogError("NO BUILD COLLECTION SET");
                return;
            }

            if (!string.IsNullOrEmpty(androidSdkPath))
            {
                EditorPrefs.SetString("AndroidSdkRoot", androidSdkPath);
                Debug.Log("Set Android SDK root to: " + androidSdkPath);
            }

            if (!string.IsNullOrEmpty(commitID))
            {
                EditorPrefs.SetString("commitID", commitID);
                Debug.Log("Set commitID to: " + commitID);
            }

            if (!string.IsNullOrEmpty(tagName))
            {
                EditorPrefs.SetString("tagName", tagName);
                Debug.Log("Set tagName to: " + tagName);
            }

            Debug.Log("Loading Build Collection: " + collectionPath);

            // Load Build Collection
            BuildCollection collection = AssetDatabase.LoadAssetAtPath(collectionPath, typeof(BuildCollection)) as BuildCollection;

            // Run Create Command
            Create(collection, false, batchMode, buildAll, buildTag);


            UBSProcess process = LoadUBSProcess();

            try
            {
                while (true)
                {
                    process.MoveNext();
                    Debug.Log("Wait..");
                    Debug.Log("Process state: " + process.CurrentState);
                    if (process.CurrentState == UBSState.done)
                    {
                        return;
                    }
                }
            }catch (Exception pException)
            {
                Debug.LogError("Build failed due to exception: ");
                Debug.LogException(pException);
                EditorApplication.Exit(1);
            }
        }