Unity-Technologies/UnityCsReference · error · InvalidOperationException
Use DrawOutline(EntityId[], EntityId[], Color, Color, float)
Error message
Use DrawOutline(EntityId[], EntityId[], Color, Color, float) instead.
What it means
The DrawOutline overload accepting int[] arrays (instance IDs) is marked [Obsolete(..., true)] and always throws InvalidOperationException. Unity migrated the selection outline system from int instance IDs to EntityId structs; the replacement overload takes EntityId[].
Source
Thrown at Editor/Mono/Handles/Handles.cs:1544
}
// Returns actual rectangle where the camera will be rendered
internal static Rect GetCameraRect(Rect position)
{
Rect screenRect = GUIClip.Unclip(position);
Rect cameraRect = new Rect(screenRect.xMin, Screen.height - screenRect.yMax, screenRect.width, screenRect.height);
return cameraRect;
}
// Get the size of the main playModeView window
public static Vector2 GetMainGameViewSize()
{
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)
{View on GitHub (pinned to 225b0fbdb5)
Solutions
- Convert int[] instance IDs to EntityId[] and call the EntityId overload.
- Alternatively, pass Renderer[] directly and use the Renderer[]-based overloads that handle conversion internally.
Example fix
// before Handles.DrawOutline(parentIds, childIds, parentColor, childColor); // after EntityId[] parentEntityIds = Array.ConvertAll(parentIds, id => (EntityId)id); EntityId[] childEntityIds = Array.ConvertAll(childIds, id => (EntityId)id); Handles.DrawOutline(parentEntityIds, childEntityIds, parentColor, childColor);
Defensive patterns
Strategy: validation
Validate before calling
// The [Obsolete(true)] attribute makes this a compile-time error. // Replace int[] overloads with EntityId[] overloads: EntityId[] parentIds = Array.ConvertAll(parentIntIds, id => (EntityId)id); EntityId[] childIds = Array.ConvertAll(childIntIds, id => (EntityId)id); Handles.DrawOutline(parentIds, childIds, parentColor, childColor);
Prevention
- After Unity upgrades, grep for DrawOutline calls with int[] arguments and migrate to EntityId[].
- Prefer the Renderer[] overloads which handle EntityId conversion internally.
When it happens
Trigger: Calling Handles.DrawOutline(int[], int[], Color, Color, float) from source code (compile error) or via reflection (runtime throw).
Common situations: Post-upgrade code or third-party packages that pass instance ID arrays to DrawOutline for selection outlines; common in Hierarchy or Scene view extensions.
Related errors
- Get GetSelectionOutlineIncludeExcludeList is obsolete, use G
- Use DrawOutline(EntityId[], Color, float) instead.
- 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/4579a9d6758a48f1.
Report an issue: GitHub.