fix: support Unity 2022.2 object lookup compatibility#1089
Conversation
📝 WalkthroughWalkthroughThe compatibility wrapper for Unity object finding is updated to use newer Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Adjusts the runtime compatibility helper used across the package to avoid Unity 2022.2 editor compilation failures by tightening version-gating around newer UnityEngine.Object lookup APIs.
Changes:
- Switches
FindObjectsByType(...)/FindAnyObjectByType(...)usage to start atUNITY_2022_3_OR_NEWER(instead ofUNITY_2022_2_OR_NEWER). - Keeps
FindObjectsOfType(...)/FindObjectOfType(...)as the fallback path for Unity 2022.2.x. - Adds local CS0618 pragma guards around obsolete fallback calls to keep builds warning-clean.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
This is integrated in latest patch #1097, since we need to think about how other APIs should be taken care of. Thanks for bringing it up! |
Description
Fix a Unity 2022.2 compatibility issue in
UnityFindObjectsCompat.Some Unity 2022.2 editor versions do not reliably expose the newer object lookup APIs used by the package. This caused compilation failures in projects using Unity 2022.2.1f1.
Type of Change
Changes Made
Object.FindObjectsByType(...)untilUNITY_2022_3_OR_NEWERObject.FindAnyObjectByType(...)untilUNITY_2022_3_OR_NEWERFindObjectsOfType(...)/FindObjectOfType(...)as the fallback path for Unity 2022.2.xTesting/Screenshots/Recordings
2022.2.1f12022.2.1f1after the compatibility changegit diff --checkDocumentation Updates
tools/UPDATE_DOCS_PROMPT.md(recommended)tools/UPDATE_DOCS.mdRelated Issues
Relates to Unity 2022.2.x compilation failures in
UnityFindObjectsCompat.Additional Notes
This change intentionally keeps the fix minimal and only adjusts the version gating for object lookup APIs in the compatibility helper.
Summary by CodeRabbit