예제 #1
0
        public static void Create(BuildCollection pCollection, bool pBuildAndRun, bool pBatchMode = false, bool pBuildAll = false, string pBuildTag = "")
        {
            UBSProcess p = ScriptableObject.CreateInstance <UBSProcess>();

            p.mBuildAndRun = pBuildAndRun;
            p.mBatchMode   = pBatchMode;
            p.mCollection  = pCollection;
            if (!pBuildAll)
            {
                p.mSelectedProcesses = p.mCollection.mProcesses.FindAll(obj => obj.mSelected);
            }
            else
            {
                p.mSelectedProcesses = p.mCollection.mProcesses;
            }
            p.mCurrentState = UBSState.invalid;

            if (!string.IsNullOrEmpty(pBuildTag))
            {
                foreach (var sp in p.mSelectedProcesses)
                {
                    sp.mOutputPath = AddBuildTag(sp.mOutputPath, pBuildTag);
                }
            }

            AssetDatabase.CreateAsset(p, GetProcessPath());
            AssetDatabase.SaveAssets();
        }
예제 #2
0
        public BuildProcess GetCurrentBuildProcess()
        {
            UBSProcess   ubs     = UBSProcess.LoadUBSProcess();
            BuildProcess process = ubs.GetCurrentProcess();

            return(process);
        }
        private static BuildCollection GetLastBuildCollection()
        {
            var process = UBSProcess.LoadUBSProcess();

            if (process != null)
            {
                return(process.BuildCollection);
            }
            return(null);
        }
예제 #4
0
 void Initialize()
 {
     mProcess = UBSProcess.LoadUBSProcess();
     if (mProcess == null)
     {
         mEmpty = true;
         mInit  = true;
     }
     else
     {
         EditorApplication.update -= OnUpdate;
         EditorApplication.update += OnUpdate;
     }
 }
예제 #5
0
        public static void OnPostProcessBuild(BuildTarget target, string buildPath)
        {
            if (BuildBehavior == UBSBuildBehavior.auto)
            {
                return;
            }

            buildPath = UBS.Helpers.GetProjectRelativePath(buildPath);
            UBSProcess p = UBSProcess.LoadUBSProcess();

            if (p.mCurrentState == UBSState.building && target == p.CurrentProcess.mPlatform)
            {
                if (p.CurrentProcess.mOutputPath != buildPath)
                {
                    Debug.Log(
                        string.Format("Manually selected build path \"{0}\" differs from specified UBS build path \"{1}\" in process \"{2}\". Using manually selected one.",
                                      buildPath, p.CurrentProcess.mOutputPath, p.CurrentProcessName)
                        );
                    p.CurrentProcess.mOutputPath = buildPath;
                }
                p.OnBuildDone();
            }
        }
예제 #6
0
        public override void OnInspectorGUI()
        {
            process = target as UBSProcess;

            GUILayout.Label("This asset contains progress information about the last run Build Collection. " +
                            "Build Processes can be continued, if they did not finish and have not been aborted. ",
                            EditorStyles.wordWrappedMiniLabel);
            GUILayout.Label("This is an auto generated asset. It should be excluded from version control and " +
                            "will be generated each time a build collection is built. ",
                            EditorStyles.wordWrappedMiniLabel);

            GUILayout.Label("This asset was responsible for building the following build collection. ",
                            EditorStyles.wordWrappedMiniLabel);

            EditorGUILayout.ObjectField("Build Collection", process.BuildCollection, typeof(BuildCollection), false);


            GUILayout.Space(5);
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Select Build Collection"))
            {
                Selection.activeObject = process.BuildCollection;
            }

            GUI.enabled = process.Progress < 1 &&
                          (process.CurrentState != UBSState.done && process.CurrentState != UBSState.aborted);

            if (GUILayout.Button("Continue Build"))
            {
                var window = UBSBuildWindow.CreateWindow();
                window.Focus();
            }
            GUI.enabled = true;

            GUILayout.EndHorizontal();
        }
예제 #7
0
 public void Run(BuildCollection pCollection, bool pBuildAndRun)
 {
     scrollPosition01 = Vector2.zero;
     UBSProcess.Create(pCollection, pBuildAndRun);
 }
예제 #8
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);
            }
        }
예제 #9
0
 public void Run(BuildCollection pCollection, bool pBuildAndRun)
 {
     UBSProcess.Create(pCollection, pBuildAndRun);
 }
예제 #10
0
        public void Cancel(string pMessage)
        {
            UBSProcess ubs = UBSProcess.LoadUBSProcess();

            ubs.Cancel(pMessage);
        }
예제 #11
0
        public BuildCollection GetCurrentBuildCollection()
        {
            UBSProcess ubs = UBSProcess.LoadUBSProcess();

            return(ubs.BuildCollection);
        }