| Parameter | Description |
|---|---|
| scene | The scene that Unity is processing. |
| sceneContext | Additional context about the scene being processed. |
Implement this method to receive a callback for each scene loaded during a Player build or when the Editor is in Play mode.
Unity invokes this callback for each scene loaded during any Player build and when loading a scene in Play mode.
This callback supports editing the provided scene to change its content for the target Player build. For example, you can add or remove references to project assets in that scene.
This callback doesn't support modifying the state of other assets, including creating or removing files in the project. Use it to modify only the provided scene.
Keep implementations deterministic. Avoid random values, timestamps, or external changing data sources. For more information, refer to Deterministic builds.
When changing the implementation, use AssetPostprocessor.GetVersion to increment your postprocessor value so the build process can pick up the changes on the next build.
Use AssetPostprocessor.context to register any dependency that would require an update on a subsequent build.
For more information about build callbacks, refer to Use build callbacks.
using UnityEditor; using UnityEditor.Build.Content; using UnityEngine; using UnityEngine.SceneManagement;
// Logs a message for every scene Unity processes during a Player build or in Play mode. class MyCustomBuildProcessor : AssetPostprocessor { public override uint GetVersion() => 1;
public void OnProcessScene(Scene scene, SceneImportContext sceneContext) { Debug.Log("MyCustomBuildProcessor.OnProcessScene " + scene.name); } }