[펌] Unity Editor detect when build fails
Unity3D/Editor / 2023. 9. 20. 18:44
I used the post in the 'EDIT 2' to come up with a decent solution. I don't know if it will work 100% of the time and I would love for someone to correct me if I have chosen a poor solution. This should allow me to run code before the build starts, and if the build fails or succeeds without changing the unity build pipeline.
class CustomBuildPipeline : MonoBehaviour, IPreprocessBuildWithReport, IPostprocessBuildWithReport
{
public int callbackOrder => 0;
// CALLED BEFORE THE BUILD
public void OnPreprocessBuild(BuildReport report)
{
// Start listening for errors when build starts
Application.logMessageReceived += OnBuildError;
}
// CALLED DURING BUILD TO CHECK FOR ERRORS
private void OnBuildError(string condition, string stacktrace, LogType type)
{
if (type == LogType.Error)
{
// FAILED TO BUILD, STOP LISTENING FOR ERRORS
Application.logMessageReceived -= OnBuildError;
}
}
// CALLED AFTER THE BUILD
public void OnPostprocessBuild(BuildReport report)
{
// IF BUILD FINISHED AND SUCCEEDED, STOP LOOKING FOR ERRORS
Application.logMessageReceived -= OnBuildError;
}
}
[출처] https://stackoverflow.com/questions/58840114/unity-editor-detect-when-build-fails
반응형
'Unity3D > Editor' 카테고리의 다른 글
[Editor] 에디터에서 Play 할 때, GameView Scale 초기화 문제 수정 (0) | 2024.09.06 |
---|---|
[Editor] 에디터에서 Play 할 때, GameView Scale 초기화 문제 보정 (0) | 2024.09.06 |
[에디터확장] BurstDebugInformation_DoNotShipDeleter (0) | 2023.02.10 |
[에디터확장] WindowsIL2CPPBuildBackUpThisFolderDeleter (0) | 2022.09.14 |
[링크] 유니티 씬뷰에서 UI, 오브젝트 등 모두 선택이 되지 않을 때 ( Unity Can't select object in scene view ) (0) | 2022.04.19 |