Environment
- Unity: 6.6 Alpha (6000.6.0a2) DX12
-
-
Problem
Unity 6.6 Alpha broke both object lookup APIs simultaneously with CS0619 (obsolete-as-error), making the package fail to compile even on the beta branch. Note: #1051 / #1058 fixed Unity 6.5 compat but does not cover 6.6 Alpha.
Two files affected:
1. Runtime/Serialization/UnityTypeConverters.cs (line 418)
error CS0619: 'EditorUtility.InstanceIDToObject(int)' is obsolete:
'InstanceIDToObject(int) is obsolete. Use EditorUtility.EntityIdToObject instead.'
2. Editor/Helpers/GameObjectLookup.cs (line 74)
error CS0619: 'EntityId.implicit operator EntityId(int)' is obsolete:
'EntityId will not be representable by an int in the future. This casting operator will be removed in a future version.'
Root Cause
In Unity 6.6, Unity removed the implicit int → EntityId cast AND marked InstanceIDToObject(int) as a compile error in the same version. The existing #if UNITY_6000_3_OR_NEWER / #else guards don't have a path that compiles cleanly on 6.6+.
Both direct API calls (EntityIdToObject(instanceId) and InstanceIDToObject(instanceId)) are blocked at compile time. The correct migration is EntityId.FromULong(ulong) → EntityIdToObject(EntityId), but the affected code sites only have an int instanceId available, not a ulong.
Workaround
For each affected site, add a #if UNITY_6000_6_OR_NEWER guard using reflection to bypass the compile-time restriction (the method still exists at runtime):
#if UNITY_6000_6_OR_NEWER
var method = typeof(EditorUtility).GetMethod(
"InstanceIDToObject",
System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public,
null, new[] { typeof(int) }, null);
return method != null ? (UnityEngine.Object)method.Invoke(null, new object[] { instanceId }) : null;
#elif UNITY_6000_3_OR_NEWER
return EditorUtility.EntityIdToObject(instanceId);
#321 return EditorUtility.InstanceIDToObject(instanceId);
#723 ```
A proper long-term fix would be to store/pass `EntityId` (ulong) alongside `instanceId` at the call sites so `EntityId.FromULong()` can be used directly without reflection.
## Impact
Project enters Safe Mode on first open. Cannot enter Play Mode until resolved.
Environment
betaProblem
Unity 6.6 Alpha broke both object lookup APIs simultaneously with
CS0619(obsolete-as-error), making the package fail to compile even on thebetabranch. Note: #1051 / #1058 fixed Unity 6.5 compat but does not cover 6.6 Alpha.Two files affected:
1.
Runtime/Serialization/UnityTypeConverters.cs(line 418)2.
Editor/Helpers/GameObjectLookup.cs(line 74)Root Cause
In Unity 6.6, Unity removed the implicit
int → EntityIdcast AND markedInstanceIDToObject(int)as a compile error in the same version. The existing#if UNITY_6000_3_OR_NEWER/#elseguards don't have a path that compiles cleanly on 6.6+.Both direct API calls (
EntityIdToObject(instanceId)andInstanceIDToObject(instanceId)) are blocked at compile time. The correct migration isEntityId.FromULong(ulong)→EntityIdToObject(EntityId), but the affected code sites only have anintinstanceId available, not a ulong.Workaround
For each affected site, add a
#if UNITY_6000_6_OR_NEWERguard using reflection to bypass the compile-time restriction (the method still exists at runtime):