`OnBuildError` is not called if `PrepareBuild` throws an exception
Closed this issue · 2 comments
OnBuildError
is called if BuildPipeline.BuildPlayer
(called within BuildSync
) fails. The same cannot be said if PrepareBuild
fails.
It seems that's only the case for PrepareBuild
? If an option throws an exception in PrepareBuild
or the exception on Manager.cs#L474 is hit, OnBuildError
won't be called.
But for the native Unity events like OnPreprocessBuild
and OnProcessScene
, the exception should be reported by Unity as an error in the build report. Or are there cases where Unity allows the exception to reach BuildSync
?
It seems the main challenge is that we don't have a BuildReport
at that time and cannot create one. So the OnBuildError
has to be changed to include an additional error parameter and pass null
for the report.
I think I made the assumption that OnBuildError
wouldn't be reached from the other build phases. PrepareBuild
is indeed the only one I've actually observed.
I'll go ahead and send a PR for that suggested change later today.