Skip to content

CS0619: Object.GetInstanceID() obsolete error in RaycastGridAnnotator.cs on Unity 6000.4+ (follow-up to #1118) #1732

Description

@clayAndromeda

Describe the bug

Following up on #1118: the fix there covered ComponentPropertySerializer.cs and HierarchyService.cs, but RaycastGridAnnotator.cs has the same Object.GetInstanceID() call and was missed. On Unity 6000.5.3f1 this still fails with CS0619 since GetInstanceID() is obsolete-as-error starting Unity 6.4 (6000.4).

Error Logs

Library\PackageCache\io.github.hatayama.uloopmcp@dbad4312a1f2\Editor\Utils\RaycastGridAnnotator.cs(376,20): error CS0619: 'Object.GetInstanceID()' is obsolete: 'GetInstanceID is deprecated. Use GetEntityId instead. This will be removed in a future version.'

Location

https://github.com/hatayama/unity-cli-loop/blob/main/Packages/src/Editor/Utils/RaycastGridAnnotator.cs#L376

internal static int CreateClusterKey(Collider collider)
{
    Debug.Assert(collider != null, "Collider is required for raycast clustering.");

    // A placement area can use several colliders on one object; one annotation should describe the clickable object.
    return collider!.gameObject.GetInstanceID();
}

Suggested fix

Apply the same UNITY_6000_4_OR_NEWER conditional pattern used in the #1118 fix for the other two files:

internal static int CreateClusterKey(Collider collider)
{
    Debug.Assert(collider != null, "Collider is required for raycast clustering.");

    // A placement area can use several colliders on one object; one annotation should describe the clickable object.
#if UNITY_6000_4_OR_NEWER
    return (int)UnityEngine.EntityId.ToULong(collider!.gameObject.GetEntityId());
#else
    return collider!.gameObject.GetInstanceID();
#endif
}

Environment

  • Unity: 6000.5.3f1
  • Package: io.github.hatayama.uloopmcp 2.2.0 (git install)

Repro steps

  1. Install the package via git URL on Unity 6000.5.3f1 (or any Unity 6000.4+ version)
  2. Let the Editor resolve/compile the package
  3. Observe CS0619 compile error at RaycastGridAnnotator.cs:376

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions