Skip to content

Commit 5d46f33

Browse files
svc-reach-platform-supportEvergreen
authored andcommitted
[Port] [6000.0] [URP] Make error when trying to use URP api out of URP for volume more explicite
Fix [UUM-91000](https://jira.unity3d.com/browse/UUM-91000). This is indeed a regression but the previously allowed of being able to call this out of URP lifetime was a mistake. One cannot alter the volume for the rendering before the URP pipeline is created. So the fix for this is mainly to clarify the error message and encouraging user to use the pipeline creation event if they need to. Before this PR, the error was `NullReferenceException: Object reference not set to an instance of an object` when calling Universal.CameraExtensions.UpdateVolumeStack before URP is created. This happens by calling it in a Start of a Script and entering play mode. New Error message: `UpdateVolumeStack must not be called before VolumeManager.instance.Initialize. If you tries calling this from Awake or Start, try instead to use the RenderPipelineManager.activeRenderPipelineCreated callback to be sure your render pipeline is fully initialized before calling this`
1 parent f7451bf commit 5d46f33

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

Packages/com.unity.render-pipelines.universal/Runtime/UniversalAdditionalCameraData.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,14 @@ public static void UpdateVolumeStack(this Camera camera, UniversalAdditionalCame
204204
{
205205
Assert.IsNotNull(cameraData, "cameraData can not be null when updating the volume stack.");
206206

207+
// UUM-91000: The UpdateVolumeStack may happens before the pipeline is constructed.
208+
// Repro: enter play mode with a script that trigger this API at Start.
209+
if (!VolumeManager.instance.isInitialized)
210+
{
211+
Debug.LogError($"{nameof(UpdateVolumeStack)} must not be called before {nameof(VolumeManager)}.{nameof(VolumeManager.instance)}.{nameof(VolumeManager.instance.Initialize)}. If you tries calling this from Awake or Start, try instead to use the {nameof(RenderPipelineManager)}.{nameof(RenderPipelineManager.activeRenderPipelineCreated)} callback to be sure your render pipeline is fully initialized before calling this.");
212+
return;
213+
}
214+
207215
// We only update the local volume stacks for cameras set to ViaScripting.
208216
// Otherwise it will be updated in the frame.
209217
if (cameraData.requiresVolumeFrameworkUpdate)

0 commit comments

Comments
 (0)