Hi, I was going through this code: DOTSSample/Assets/Scripts/Build/Editor/ScenePostProcessor.cs at master · Unity-Technologies/DOTSSample · GitHub
And from what I can tell, the isDevelopmentBuild
boolean is never modified anywhere, I even tried to look it up from an IDE.
And so I wanted to ask if there is some way to determine which type of a build it is (release, or debug) from a PostProcessScene
callback.
Solutions I have considered:
- Use
IProcessSceneWithReport
- The same problem, don’t know how to determine the build type.
- Use
DEVELOPMENT_BUILD
define - Only true in a player, will be false in the editor.
- Use
DEBUG
- will always be true inside the editor.
- Use a manual define - not enough automation for my programmer tastes, but is the fallback plan if I can’t find any solutions.
Old question, but for those still facing this problem you can use IProcessSceneWithReport
and use report.summary.options.HasFlag(BuildOptions.Development)
to determine if it’s a development build. As said in Unity docs, IProcessSceneWithReport.OnProcessScene
will also run when playing a scene in the Editor, so you need to check BuildPipeline.isBuildingPlayer
if you want to run code only when building.
Here’s a quick example:
public class SomeSceneProcessor : IProcessSceneWithReport
{
public int callbackOrder => 0;
public void OnProcessScene(Scene scene, BuildReport report)
{
// Make sure it runs only for builds and not
// when playing the scene in the Editor.
if (!BuildPipeline.isBuildingPlayer)
{
return;
}
if (report.summary.options.HasFlag(BuildOptions.Development))
{
// Code for development builds.
}
else
{
// Code for release builds.
}
}
}
1 Like