Unity - Scripting API: Build.IPreprocessBuildWithContext.OnPreprocessBuild
Success!
Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.
Submission failed
For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.
Parameters
| Parameter | Description |
|---|---|
| ctx | A context containing information about the build, such as its build report. |
Description
Implement this method to receive a callback before the build is started.
using UnityEditor; using UnityEditor.Build; using UnityEngine; using UnityEditor.Build.Reporting;class MyCustomBuildProcessor : IPreprocessBuildWithContext { public int callbackOrder { get { return 0; } } public void OnPreprocessBuild(BuildCallbackContext ctx) { if (ctx.IsContentOnlyBuild) Debug.Log("AssetBundle build: MyCustomBuildProcessor.OnPreprocessBuild for target " + ctx.Report.summary.platform + " at path " + ctx.Report.summary.outputPath); else if (ctx.IsPlayerBuild) Debug.Log("Player build: MyCustomBuildProcessor.OnPreprocessBuild for target " + ctx.Report.summary.platform + " at path " + ctx.Report.summary.outputPath); } }