Version: Unity 6.3 LTS (6000.3)
LanguageEnglish
  • C#

IProcessSceneWithReport.OnProcessScene

Suggest a change

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.

Close

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.

Close

Cancel

Declaration

public void OnProcessScene(SceneManagement.Scene scene, Build.Reporting.BuildReport report);

Parameters

Parameter Description
scene The current scene being processed.
report A report containing information about the current build. When this callback is invoked for scene loading during Play mode, this parameter is null.

Description

Implement this method to receive a callback for each scene during the build.

Unity invokes this callback during Player and AssetBundle builds, and also when a scene is reloaded while entering Play mode. Use BuildPipeline.isBuildingPlayer to determine in which context the callback is called.

This callback supports editing the provided scene to prepare it for a Player build or entering Play mode, and reading assets. 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. 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.

Apply BuildCallbackVersionAttribute to callback types and increment the version whenever the callback logic changes to help Unity invalidate cached scene processing results when needed.

For more information about build callbacks, refer to Use build callbacks.

using UnityEditor;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
using UnityEngine;

[BuildCallbackVersion(1)] class MyCustomBuildProcessor : IProcessSceneWithReport { public int callbackOrder { get { return 0; } } public void OnProcessScene(UnityEngine.SceneManagement.Scene scene, BuildReport report) { Debug.Log("MyCustomBuildProcessor.OnProcessScene " + scene.name); } }