This repository was archived by the owner on Sep 20, 2026. It is now read-only.
fix(overlays): avoid version-specific scene handle access - #327
Merged
Merged
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The functional fix is targeted and backed by a compiled-artifact regression test; only a minor doc-comment tweak was noted.
Pull request overview
This PR fixes overlay panels not appearing on newer Unity runtimes by removing the mod’s runtime binding to the version-specific UnityEngine.SceneManagement.Scene.handle getter and instead comparing Scene values via the stable Scene.op_Equality ABI, with a regression test that inspects the compiled DLL’s PE metadata.
Changes:
- Replace
Scene.handle-based scene-token caching withScenevalue comparisons in overlay panel hosting. - Update active-scene name caching to avoid
Scene.handleaccess in per-frame callers. - Add a runtime integration test that scans
BazaarPlusPlus.dllmetadata to ensureget_handleis not referenced andop_Equalityis referenced.
File summaries
| File | Description |
|---|---|
| tests/RuntimeIntegration.Tests/SceneRuntimeCompatibilityTests.cs | Adds a PE-metadata guard test to prevent reintroducing Scene.get_handle references. |
| src/BazaarPlusPlus/GameInterop/Scenes/ActiveSceneNameCache.cs | Switches scene cache identity from scene.handle to Scene equality to avoid runtime ABI mismatch. |
| src/BazaarPlusPlus/Game/OverlayPanels/OverlayPanelHost.cs | Updates scene token caching to compare Scene values instead of calling Scene.handle. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| internal static class ActiveSceneNameCache | ||
| { | ||
| private static int _handle; | ||
| private static Scene _scene; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
点击 Collection 图标或按 Tab 后面板不显示。当前游戏的 Unity Player.log 持续报告
MissingMethodException: int UnityEngine.SceneManagement.Scene.get_handle(),调用点为OverlayPanelHost.Update和 dock 按钮的LateUpdate。项目通过 UnityEngine.Modules 编译时绑定到旧版返回 int 的 getter,而已安装 Unity 6.3 的 Scene.handle 返回 SceneHandle。构建成功不能证明运行时方法签名兼容。
方案讨论
场景缓存只需要判断是否为同一个场景,无需读取 handle 数值。直接缓存 Scene,并使用签名未改变的
Scene.op_Equality(Scene, Scene),避免引入反射或特定 Unity 版本类型。最终方案
验证情况
run.sh buildRelease:通过,0 warning / 0 error。已知局限 / 后续工作
本次修复 Scene.handle 的二进制签名兼容性;图标间距是否还有独立布局问题需以实机结果为准。