Unity-Technologies/UnityCsReference · error · InvalidOperationException
renderingLayerNames is null or empty
Error message
renderingLayerNames is null or empty
What it means
Thrown by TryMigrateRenderingLayersToTagManager when renderingLayerNames is null or has zero length. Despite the Try* prefix, the method enforces non-empty input by throwing rather than returning false.
Source
Thrown at Editor/Mono/Inspector/RenderPipelineEditorUtility.cs:101
public static bool TryRemoveLastRenderingLayerName()
=> TagManager.Internal_TryRemoveLastRenderingLayerName();
[AutoStaticsCleanupOnCodeReload]
public static Action onRenderingLayerCountChanged;
/// <summary>
/// Migrate Rendering Layers data from Global Settings to Tags and Layers.
/// </summary>
/// <param name="renderingLayerNames">A list of rendering layer names.</param>
/// <typeparam name="T">Render Pipeline type.</typeparam>
/// <returns>Returns true if it was succesful.</returns>
/// <exception cref="InvalidOperationException">Throw an exception if rendering layer names list is null or empty.</exception>
internal static bool TryMigrateRenderingLayersToTagManager<T>(string[] renderingLayerNames)
where T: RenderPipeline
{
if (renderingLayerNames == null || renderingLayerNames.Length == 0)
throw new InvalidOperationException("renderingLayerNames is null or empty");
var renderPipelineFullName = typeof(T).FullName;
var trimmedNames = new string[renderingLayerNames.Length];
for (int i = 0; i < renderingLayerNames.Length; i++)
{
trimmedNames[i] = renderingLayerNames[i]?.Trim() ?? string.Empty;
}
return TagManager.TryMigrateRenderingLayers(renderPipelineFullName, trimmedNames);
}
internal static void ClearMigratedRenderPipelines()
{
TagManager.ClearMigratedRenderPipelines();
}
/// <summary>
/// Retrieves the maximum number of rendering layers supported by the currently active render pipeline.View on GitHub (pinned to 225b0fbdb5)
Solutions
- Check renderingLayerNames != null && renderingLayerNames.Length > 0 before calling.
- Populate the rendering layer names list in the pipeline's global settings before migration.
- If no layers exist, skip migration rather than calling with an empty list.
Example fix
// before
RenderPipelineEditorUtility.TryMigrateRenderingLayersToTagManager<MyRP>(names);
// after
if (names != null && names.Length > 0)
RenderPipelineEditorUtility.TryMigrateRenderingLayersToTagManager<MyRP>(names); Defensive patterns
Strategy: validation
Validate before calling
bool ok = renderingLayerNames != null && renderingLayerNames.Length > 0;
Prevention
- Pre-check the array is non-null and non-empty.
- Populate layer names in global settings before migration.
When it happens
Trigger: Calling TryMigrateRenderingLayersToTagManager with a null or empty string[] when migrating rendering layer names from a render pipeline's global settings to the Tags and Layers manager.
Common situations: Migrating rendering layers for a pipeline whose global settings have no layer names configured. Custom render pipelines that forgot to populate the layer name list. Running migration on a fresh project.
Related errors
- Attempting to set an incorrect number of icons for {namedBui
- The setting label can't be null or empty.
- Given rpAssetType must derive from RenderPipelineAsset
- One or more transforms are null
- Prefab Mode: GameObject must be part of a Prefab instance, o
AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13).
Data as JSON: /api/errors/6030c19285072cc2.
Report an issue: GitHub.