Unity-Technologies/UnityCsReference · warning · InvalidOperationException

GlobalObjectId.GetGlobalObjectIdSlow(int[], [Out] GlobalObje

Error message

GlobalObjectId.GetGlobalObjectIdSlow(int[], [Out] GlobalObjectId[]) is obsolete. Use GlobalObjectId.GetGlobalObjectIdSlow(EntityId[], [Out] GlobalObjectId[]).

What it means

GetGlobalObjectIdsSlow(int[], GlobalObjectId[]) is marked [Obsolete(..., true)] (treat-as-error) and its body throws InvalidOperationException directing callers to the EntityId[] overload. This is part of the instance-id-to-EntityId migration: int instance IDs are being phased out in favor of the strongly-typed EntityId.

Source

Thrown at Editor/Mono/GlobalObjectId.bindings.cs:48

        // Converts an Object reference to a global unique ID
        [FreeFunction]
        extern public static GlobalObjectId GetGlobalObjectIdSlow(UnityEngine.Object targetObject);

        [FreeFunction]
        extern public static void GetGlobalObjectIdsSlow(UnityEngine.Object[] objects, [Out] GlobalObjectId[] outputIdentifiers);

        [Obsolete("GlobalObjectId.GetGlobalObjectIdSlow(int) is obsolete. Use GlobalObjectId.GetGlobalObjectIdSlow(EntityId) instead.", true)]
        public static GlobalObjectId GetGlobalObjectIdSlow(int instanceId)
        {
            return GetGlobalObjectIdSlow((EntityId)instanceId);
        }

        [Obsolete(
            "GlobalObjectId.GetGlobalObjectIdSlow(int[], [Out] GlobalObjectId[]) is obsolete. Use GlobalObjectId.GetGlobalObjectIdSlow(EntityId[], [Out] GlobalObjectId[]) is obsolete instead.",
            true)]
        public static void GetGlobalObjectIdsSlow(int[] instanceIds, [Out] GlobalObjectId[] outputIdentifiers)
        {
            throw new InvalidOperationException(
                "GlobalObjectId.GetGlobalObjectIdSlow(int[], [Out] GlobalObjectId[]) is obsolete. Use GlobalObjectId.GetGlobalObjectIdSlow(EntityId[], [Out] GlobalObjectId[]).");
        }

        // Converts an Object reference to a global unique ID
        public static GlobalObjectId GetGlobalObjectIdSlow(EntityId entityid)
        {
            return GetGlobalObjectIdFromInstanceIdSlow(entityid);
        }

        public static void GetGlobalObjectIdsSlow(EntityId[] entityIds, [Out] GlobalObjectId[] outputIdentifiers)
        {
            GetGlobalObjectIdsFromInstanceIdsSlow(entityIds, outputIdentifiers);
        }

        // Converts an Object reference to a global unique ID
        [FreeFunction]
        extern static GlobalObjectId GetGlobalObjectIdFromInstanceIdSlow(EntityId instanceId);

View on GitHub (pinned to 225b0fbdb5)

Solutions

  1. Replace int[] instanceIds with EntityId[] and call GetGlobalObjectIdsSlow(EntityId[], GlobalObjectId[]).
  2. If you hold raw ints, convert via (EntityId)instanceId at the call site or upstream.
  3. Update dependent packages to versions that target the new API.

Example fix

// before
int[] ids = ...;
GlobalObjectId.GetGlobalObjectIdsSlow(ids, output);

// after
EntityId[] ids = ...; // or ids.Select(i => (EntityId)i).ToArray()
GlobalObjectId.GetGlobalObjectIdsSlow(ids, output);
Defensive patterns

Strategy: type-guard

Validate before calling

// migrate ints to EntityIds before the call
EntityId[] eids = Array.ConvertAll(instanceIds, i => (EntityId)i);
GlobalObjectId.GetGlobalObjectIdsSlow(eids, outputIdentifiers);

Prevention

When it happens

Trigger: Calling GlobalObjectId.GetGlobalObjectIdsSlow with an int[] (legacy instance IDs); compiling code written against an older Unity API; a library that has not migrated to EntityId.

Common situations: Upgrading Unity across the instance-id->EntityId boundary; third-party package built pre-migration; auto-upgrade tooling that left int[] calls intact.

Related errors


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