Unity-Technologies/UnityCsReference · error · InvalidOperationException
Use DrawOutline(EntityId[], Color, float) instead.
Error message
Use DrawOutline(EntityId[], Color, float) instead.
What it means
The single-array DrawOutline overload accepting int[] (instance IDs) is marked [Obsolete(..., true)] and always throws InvalidOperationException. The replacement overload takes EntityId[] and is the only way to draw a single-group outline.
Source
Thrown at Editor/Mono/Handles/Handles.cs:1556
{
return PlayModeView.GetMainPlayModeViewTargetSize();
}
[Obsolete("Deprecated. Use DrawOutline(EntityId[], EntityId[], Color, Color, float) instead.",true)]
public static void DrawOutline(int[] parentRenderers, int[] childRenderers, Color parentNodeColor, Color childNodeColor, float fillOpacity = 0)
=> throw new InvalidOperationException(
"Use DrawOutline(EntityId[], EntityId[], Color, Color, float) instead.");
public static void DrawOutline(EntityId[] parentRenderers, EntityId[] childRenderers, Color parentNodeColor, Color childNodeColor, float fillOpacity = 0)
{
if(Event.current.type != EventType.Repaint)
return;
Internal_DrawOutline(parentNodeColor, childNodeColor, EntityId.None, parentRenderers, childRenderers, OutlineDrawMode.SelectionOutline, fillOpacity, fillOpacity);
Internal_FinishDrawingCamera(Camera.current, true);
}
[Obsolete("Deprecated. Use DrawOutline(EntityId[], Color, float) instead.", true)]
public static void DrawOutline(int[] renderers, Color color, float fillOpacity = 0) =>
throw new InvalidOperationException(
"Use DrawOutline(EntityId[], Color, float) instead.");
public static void DrawOutline(EntityId[] renderers, Color color, float fillOpacity = 0) =>
DrawOutline(renderers, null, color, color, fillOpacity);
public static void DrawOutline(Renderer[] renderers, Color parentNodeColor, Color childNodeColor, float fillOpacity = 0)
{
EntityId[] parentRenderers, childRenderers;
HandleUtility.FilterRendererIDs(renderers, out parentRenderers, out childRenderers);
DrawOutline(parentRenderers, childRenderers, parentNodeColor, childNodeColor, fillOpacity);
}
public static void DrawOutline(Renderer[] renderers, Color color, float fillOpacity = 0) =>
DrawOutline(renderers, color, color, fillOpacity);
public static void DrawOutline(GameObject[] objects, Color parentNodeColor, Color childNodeColor, float fillOpacity = 0)
{
EntityId[] parentRenderers, childRenderers;
HandleUtility.FilterEntityIds(objects, out parentRenderers, out childRenderers, out _);View on GitHub (pinned to 225b0fbdb5)
Solutions
- Convert int[] to EntityId[] and call DrawOutline(EntityId[], Color, float).
- Alternatively, pass Renderer[] directly to the Renderer[]-based overload.
Example fix
// before Handles.DrawOutline(rendererIds, color, 0.5f); // after EntityId[] entityIds = Array.ConvertAll(rendererIds, id => (EntityId)id); Handles.DrawOutline(entityIds, color, 0.5f);
Defensive patterns
Strategy: validation
Validate before calling
// The [Obsolete(true)] attribute makes this a compile-time error. // Replace the int[] overload with the EntityId[] overload: EntityId[] entityIds = Array.ConvertAll(intIds, id => (EntityId)id); Handles.DrawOutline(entityIds, color, fillOpacity);
Prevention
- After Unity upgrades, grep for DrawOutline calls with a single int[] argument and migrate to EntityId[].
- Prefer the Renderer[] overload for convenience when you have Renderer references.
When it happens
Trigger: Calling Handles.DrawOutline(int[], Color, float) from source code (compile error) or via reflection (runtime throw).
Common situations: Existing editor code or third-party packages that draw selection outlines from instance ID arrays after a Unity version upgrade.
Related errors
- Get GetSelectionOutlineIncludeExcludeList is obsolete, use G
- Use DrawOutline(EntityId[], EntityId[], Color, Color, float)
- Get GetPickingIncludeExcludeList is obsolete, use GetPicking
- HierarchyProperty is deprecated. Use HierarchyIterator inste
- GetRenderersFilteringResults(ReadOnlySpan<int>) is obsolete.
AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13).
Data as JSON: /api/errors/4df5de37bdc97108.
Report an issue: GitHub.