Unity-Technologies/UnityCsReference · error · InvalidOperationException

Get GetPickingIncludeExcludeList is obsolete, use GetPicking

Error message

Get GetPickingIncludeExcludeList is obsolete, use GetPickingIncludeExcludeEntityIdList instead.

What it means

GetPickingIncludeExcludeList is marked [Obsolete(..., true)] — the 'true' flag makes any direct call a compiler error. The method body also throws InvalidOperationException unconditionally if invoked via reflection. Unity migrated the picking system from int instance IDs to EntityId structs; the replacement is GetPickingIncludeExcludeEntityIdList.

Source

Thrown at Editor/Mono/Handles/HandleUtility.cs:1232

            return new PickingIncludeExcludeEntityIdList(s_RendererIncludeBuffer, s_RendererExcludeBuffer, s_EntityIncludeBuffer, s_EntityExcludeBuffer, allocator);
        }

        public static PickingIncludeExcludeEntityIdList GetSelectionOutlineIncludeExcludeEntityIdList(Allocator allocator = Allocator.Persistent)
        {
            s_RendererIncludeBuffer.Clear();
            s_RendererExcludeBuffer.Clear();
            s_EntityIncludeBuffer.Clear();
            s_EntityExcludeBuffer.Clear();
            Renderer[] deepSelection = Selection.GetFiltered<Renderer>(SelectionMode.Deep);
            ExtractRenderersEntityIds(deepSelection, s_RendererIncludeBuffer);
            ExtractEntities(Selection.objects, s_EntityIncludeBuffer);
            return new PickingIncludeExcludeEntityIdList(s_RendererIncludeBuffer, null, s_EntityIncludeBuffer, null, allocator);
        }

        [Obsolete("Use GetPickingIncludeExcludeEntityIdList instead. This method will be removed in a future version.", true)]
        public static PickingIncludeExcludeList GetPickingIncludeExcludeList(Allocator allocator = Allocator.Persistent)
        {
            throw new InvalidOperationException("Get GetPickingIncludeExcludeList is obsolete, use GetPickingIncludeExcludeEntityIdList instead.");
        }

        [Obsolete("Use GetSelectionOutlineIncludeExcludeEntityIdList instead. This method will be removed in a future version.", true)]
        public static PickingIncludeExcludeList GetSelectionOutlineIncludeExcludeList(Allocator allocator = Allocator.Persistent)
        {
            throw new InvalidOperationException("Get GetSelectionOutlineIncludeExcludeList is obsolete, use GetSelectionOutlineIncludeExcludeEntityIdList instead.");
        }

        internal static PickingObject PickObject(Vector2 guiPosition,
            bool selectPrefabRoot = false,
            List<PickingObject> ignore = null,
            List<PickingObject> filter = null)
        {
            Camera cam = Camera.current;
            int layers = cam.cullingMask;
            var screenPosition = GUIPointToScreenPixelCoordinate(guiPosition);
            var sceneView = SceneView.lastActiveSceneView;
            bool drawGizmos = sceneView != null && sceneView.drawGizmos;

View on GitHub (pinned to 225b0fbdb5)

Solutions

  1. Replace all calls to GetPickingIncludeExcludeList with GetPickingIncludeExcludeEntityIdList, which returns PickingIncludeExcludeEntityIdList.
  2. Update third-party editor packages to versions compatible with the current Unity editor.
  3. If invoking via reflection, remove the reflection path and call the new API directly.

Example fix

// before
var list = HandleUtility.GetPickingIncludeExcludeList(Allocator.Persistent);
// after
var list = HandleUtility.GetPickingIncludeExcludeEntityIdList(Allocator.Persistent);
Defensive patterns

Strategy: validation

Validate before calling

// The [Obsolete(true)] attribute makes this a compile-time error.
// Grep the codebase and replace:
//   HandleUtility.GetPickingIncludeExcludeList
//   -> HandleUtility.GetPickingIncludeExcludeEntityIdList

Prevention

When it happens

Trigger: Calling HandleUtility.GetPickingIncludeExcludeList() from source code (caught at compile time) or invoking it dynamically via reflection (throws at runtime).

Common situations: Upgrading a Unity project across a version boundary where the picking API changed from int[] to EntityId[]; older editor extensions or third-party packages still reference the old method name.

Related errors


AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13). Data as JSON: /api/errors/28fecd353feaced7. Report an issue: GitHub.