Esempio n. 1
0
        /// <summary>
        /// Operations to be performed before build.
        /// </summary>
        /// <param name="report">Report to add things to.</param>
        public void OnPreprocessBuild(BuildReport report)
        {
            // This makes sure the logger is initialized even if the game hasn't been run on editor.
            LogHandler.Initialize();

            Logger.Info("Building to " + report.summary.outputPath + ".");

            bool buildSuccessful = GenerateVersion();

            BuildProcessorHookLibrary hookLibrary = LoadHookLibrary("preprocessing");

            if (hookLibrary != null)
            {
                for (int i = 0; i < hookLibrary.PreProcessorHooks.Length; ++i)
                {
                    if (!hookLibrary.PreProcessorHooks[i].RunHook(report.summary.outputPath))
                    {
                        buildSuccessful = false;
                    }
                }
            }

            if (buildSuccessful)
            {
                Logger
                .Info("Successfully preprocessed build.");
            }
            else
            {
                Logger
                .Error("There was an error preprocessing the build, check the console.");
            }
        }
Esempio n. 2
0
        private static BuildProcessorHookLibrary LoadHookLibrary(string mode)
        {
            StaticLogger.Info("Loading " + mode + " hook library...");

            BuildProcessorHookLibrary hookLibrary =
                AssetDatabase.LoadAssetAtPath <BuildProcessorHookLibrary>("Assets/Data/BuildProcessorHooks.asset");

            StaticLogger
            .Info(hookLibrary == null
                         ? "No hook library found. No custom build " + mode + " hooks added."
                         : "Loaded custom build " + mode + " hooks.");

            return(hookLibrary);
        }
Esempio n. 3
0
        [PostProcessBuild(0)] // First to be called after build.
        public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject)
        {
            bool buildSuccessful = true;
            // ReSharper disable once PossibleNullReferenceException
            string buildFolder = Directory.GetParent(pathToBuiltProject).FullName;

            if (target == BuildTarget.StandaloneWindows ||
                target == BuildTarget.StandaloneWindows64 ||
                target == BuildTarget.StandaloneLinux64 ||
                target == BuildTarget.StandaloneOSX)
            {
                try
                {
                    CopyConfigFolder(buildFolder);
                }
                catch (Exception e)
                {
                    buildSuccessful = false;
                    StaticLogger.Error("Exception!", e);
                }
            }
            else
            {
                StaticLogger.Info("Target is not standalone, skipping config copy.");
            }

            BuildProcessorHookLibrary hookLibrary = LoadHookLibrary("postprocessing");

            if (hookLibrary != null)
            {
                for (int i = 0; i < hookLibrary.PostProcessorHooks.Length; ++i)
                {
                    if (!hookLibrary.PostProcessorHooks[i].RunHook(pathToBuiltProject))
                    {
                        buildSuccessful = false;
                    }
                }
            }

            if (buildSuccessful)
            {
                StaticLogger.Info("Successfully postprocessed build in " + buildFolder + ".");
            }
            else
            {
                StaticLogger.Error("There was an error postprocessing the build, check the console.");
            }
        }
Esempio n. 4
0
        public static void CreateBuildProcessorHooksLibrary()
        {
            if (!Directory.Exists("/Assets/Data"))
            {
                Directory.CreateDirectory("/Assets/Data");
            }
            BuildProcessorHookLibrary library = ScriptableObject.CreateInstance <BuildProcessorHookLibrary>();

            AssetDatabase.CreateAsset(library, "Assets/Data/BuildProcessorHooks.asset");
            AssetDatabase.SaveAssets();

            library =
                AssetDatabase.LoadAssetAtPath <BuildProcessorHookLibrary>("Assets/Data/BuildProcessorHooks.asset");

            Selection.activeObject = library;
        }