Unity version 2021.3.7,URP
I just add “Debug.Log(“prebuild start”);” in OnPreprocessBuild;
No debugInfo at console,I’ve implemented the IPreprocessBuildWithReport.
Could anyone help me?
Unity version 2021.3.7,URP
I just add “Debug.Log(“prebuild start”);” in OnPreprocessBuild;
No debugInfo at console,I’ve implemented the IPreprocessBuildWithReport.
Could anyone help me?
anyone help?
Do you mean that you’re doing the same thing as in this example, and you’re not getting any callbacks?
I just tried it, callbacks for sure fire with that code exactly copy-pasted
Thanks,it works in Editor Log file.
But why the debugInfo not show in unityConsole?
If a Debug.Log shows up in the editor log, it shows up in the console.
I checked, clear on build happens before OnPreprocessBuild, so that’s not the culprit. Sure you haven’t turned the Deb ug.Log toggle off in the console window?
In my case I have to disable Clear on Recompile. Simply turning off Clear on Build is NOT enough.
My details:
Unity 2022.2.0f1
Building for Android
Development Build: checked
Backend: IL2CPP
(not sure what else would be useful)
I created a simple IPreprocessBuildWithReport script just like in the documentation’s example. When I execute a build (simply using the Build button in Build Settings) then I do NOT see the Debug.Log message in my console as long as Clear on Recompile is checked. However if I open the Editor log externally I do see my messages being printed. If I add a throw new BuildFailedException() to my method, then the build does fail and all Debug.Log messages are visible in the Console.
So it seems the callback is working as intended, but under specific circumstances between the callback completing and the build completing, a recompile happens which clears the console buffer before any messages generated during the callbacks get a chance to be sent to the Console, but they still get written to the log.
Right, so, coming back later; that is probably expected!
When you build, Unity recompiles everything (with the UNITY_EDITOR compile flag turned off, and nothing from the UnityEditor namespace available etc.) as a part of the build. Then it recompiles everything again with the old settings.
At least I believe that’s what happens! So this would cause recompiles to clear the log during a build. Which is obviously not what you want. So that’s probably a bug - otherwise the clear on build flag wouldn’t be there!
That being said, I’ve never used clear on recompile, so that was probably why I wasn’t able to reproduce the issue OP was seeing.
Hi, I’am here with the same problem and can’t find any solution and no more ideas what is wrong here.
I’am just copy the example from the docs in my project. IDE says: no problem, Editor compiles and says no problem. But when I’am hit build, Unity can’t find UnityEditor.Build anymore.
But the worst thing is, that the code in the example function was executed: see the first message in the log.
I’am on Unity 2022.3.15 and make use of Addressables build while building the player. Cloud this be the source of the Problem?
Thanks
Yeah, that’s to be expected. Code in UnityEditor.Build (or in UnityEditor in general) can’t got into built games. This makes sense, you don’t need the code that builds the game in the game itself!
Make sure that your build script is in an editor assembly - either under an asmdef that’s only included in the editor, or under an Editor/ folder if you’re not using asmdefs.
Sure m-( Thank you very much!