Add this attribute to a method to get a callback just after a Player build completes.
// C# example: using UnityEngine; using UnityEditor; using UnityEditor.Callbacks;
public class MyBuildPostprocessor { [PostProcessBuildAttribute(1)] public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject) { Debug.Log( pathToBuiltProject ); } }
PostProcessBuildAttribute is the attribute-based form of the IPostprocessBuildWithReport callback. Unity tracks and invokes both together, in callback order, with the same behavior, and both run only for Player builds. The attribute method receives the BuildTarget and the output path, while IPostprocessBuildWithReport receives a BuildReport. If the build fails or is canceled, this callback is not invoked.
Use IPostprocessBuildWithContext for new code. It also runs for AssetBundle and content directory builds, and it runs even when a build fails or is canceled.
PostProcessBuildAttribute has an option to provide an order index for the callback, starting at 0. This is useful if you have more than one PostProcessBuildAttribute or IPostprocessBuildWithReport callback and you want them called in a certain order. Callbacks are called in order, starting at zero.
Additional resources: IPostprocessBuildWithContext, IPostprocessBuildWithReport, Use build callbacks