コード例 #1
0
        internal static void OnBuildEnded()
        {
            expectedScenesNames = null;
            if (s_buildSession == null)
            {
                throw new System.InvalidOperationException("Build was not in progress");
            }

            try
            {
                using (s_buildSession)
                {
                    if (s_buildSession.deferAnalysis)
                    {
                        s_buildSession.PostProcessBuild(s_buildSession.buildTarget, s_buildSession.buildPath, scenes =>
                        {
                            return(BuildLogParser.GetLastBuildAssetsSizes(EditorLogPath, scenes));
                        });
                    }
                    else if (s_buildSession.buildTimer.IsRunning)
                    {
                        Log.Warning("The build seems to have failed or been interrupted");
                    }
                }
            }
            finally
            {
                s_buildSession = null;
            }
        }
コード例 #2
0
 private void CleanUpIfBuildFailed()
 {
     Debug.Assert(activeInstance == this);
     Log.Warning("The build seems to have failed or been interrupted");
     CleanUp();
     activeInstance = null;
 }
コード例 #3
0
        public static void OnPostprocessBuild(BuildTarget target, string path)
        {
            if (!BetterBuildInfo.IsEnabled)
            {
                return;
            }

            if (!BuildInfoSettings.Instance.useLegacyCallbacks)
            {
                return;
            }

            if (s_buildSession == null)
            {
                Log.Error("Somehow the tool hasn't recognized that the build is in progress");
                return;
            }

            if (UnityVersionAgnostic.AssetLogPrintedAfterPostProcessors)
            {
                Log.Debug("This Unity version prints assets usage *after* post processors are run (possibly a bug); deferring the analysis to the first editor update after the build.");
                s_buildSession.buildTarget   = target;
                s_buildSession.buildPath     = path;
                s_buildSession.deferAnalysis = true;
            }
            else
            {
                try
                {
                    using (s_buildSession)
                    {
                        s_buildSession.PostProcessBuild(target, path, scenes =>
                        {
                            return(BuildLogParser.GetLastBuildAssetsSizes(EditorLogPath, scenes));
                        });
                    }
                }
                finally
                {
                    s_buildSession = null;
                }
            }

            return;
        }
コード例 #4
0
        void IPreprocessBuildWithReport.OnPreprocessBuild(BuildReport report)
        {
            if (activeInstance != null)
            {
                activeInstance.CleanUpIfBuildFailed();
                Debug.Assert(activeInstance == null);
            }

            if (!BetterBuildInfo.IsEnabled)
            {
                return;
            }
            if (BuildInfoSettings.Instance.useLegacyCallbacks)
            {
                return;
            }

            activeInstance = this;

            EditorSceneManager.sceneOpened += OnSceneOpened;
            EditorApplication.update       += CleanUpIfBuildFailed;
        }
コード例 #5
0
        public static void OnPostprocessScene()
        {
            if (EditorApplication.isPlayingOrWillChangePlaymode)
            {
                return;
            }

            if (!BetterBuildInfo.IsEnabled)
            {
                return;
            }

            if (!BuildInfoSettings.Instance.useLegacyCallbacks)
            {
                if (!UnityVersionAgnostic.HasNestedPrefabs)
                {
                    Log.Warning("To use new callbacks update Unity to 2018.3 or newer.");
                }
                return;
            }

            if (s_buildSession == null)
            {
                s_buildSession = new BuildInfoProcessor();
            }

            var    scene      = EditorSceneManager.GetActiveScene();
            var    sceneIndex = s_buildSession.processedScenes.Count;
            string scenePath  = scene.path;

            if (expectedScenesNames != null)
            {
                if (expectedScenesNames.Length > sceneIndex)
                {
                    scenePath = expectedScenesNames[sceneIndex];
                }
                else
                {
                    Log.Warning("SetExpectedScenesPaths was not provided with enough paths for the build (current scene no: {0} ({1})). " +
                                "Carrying on, but bad things may happen.", sceneIndex, scenePath);
                }
            }
            else if (string.IsNullOrEmpty(scenePath) || scenePath.ToLower().StartsWith("temp/"))
            {
                // oopsie
                var guessName = EditorBuildSettings.scenes.Where(x => x.enabled).Select(x => x.path).Skip(sceneIndex).FirstOrDefault();
                if (guessName != null)
                {
                    Log.Warning("Detected a temp scene ({0}), guessed it's really {1} based on editor build settings.\n" +
                                "This happens if a scene to be included in a build is opened. If you call BuildPlayer method from script " +
                                "consider calling Better.BuildInfoProcessor.SetExpectedScenesPaths first.", scenePath, guessName);

                    scenePath = guessName;
                }
                else
                {
                    Log.Warning("Detected a temp scene ({0}), but unable to guess it's real name.\n" +
                                "This happens if a scene to be included in a build is opened and you are using BuildPlayer method from script; " +
                                "consider calling Better.BuildInfoProcessor.SetExpectedScenesPaths first."
                                , guessName);
                }
            }

            s_buildSession.PostProcessScene(scene, scenePath, null);
        }