Skip to content

Unity 6 (6000.0.61f1) migration: type forwarders, save system, API updates#174

Open
leesiuuuu wants to merge 3 commits into
hk-modding:masterfrom
leesiuuuu:unity6-support
Open

Unity 6 (6000.0.61f1) migration: type forwarders, save system, API updates#174
leesiuuuu wants to merge 3 commits into
hk-modding:masterfrom
leesiuuuu:unity6-support

Conversation

@leesiuuuu
Copy link
Copy Markdown

Summary

Adapts the API to Unity 6 (6000.0.61f1) while maintaining backward
compatibility with mods compiled against the previous release.

Type forwarders for TeamCherry.* assemblies

Unity 6 split several types out of Assembly-CSharp into new assemblies:

  • TeamCherry.TK2D (tk2d sprite system — 66 types)
  • TeamCherry.Cinematics (video player — 8 types)
  • TeamCherry.Localization (language system)

PrePatcher now injects ExportedType forwarders so existing mods resolve
these types without recompilation. MMHOOK_Assembly-CSharp is similarly
patched to forward On.* / IL.* hook types from the new MMHOOK files.

Save system

GetSaveStatsForSlot override removed — vanilla Unity 6 handles JSON saves
correctly. LoadGame simplified: mod data is loaded around orig_LoadGame,
dropping ~200 lines of now-dead BinaryFormatter handling.

Unity 6 API deprecations

  • Rigidbody2D.velocitylinearVelocity (HeroController)
  • Object.FindObjectOfTypeFindFirstObjectByType (UIManager, GameCameras)
  • Null-conditional on menuButtonLists in MenuButtonList.RecalculateNavigation
  • Language.Language moved to TeamCherry.Localization: add backward-compat stub
    in Assembly-CSharp namespace, update internal usages

Testing

Built and verified against Unity 6 (6000.0.61f1) game binaries.
dotnet build Assembly-CSharp -p:Configuration=Release --runtime win-x64
produces 0 warnings, 0 errors. API loads correctly, mod initialization
runs, and save data persists across sessions.

leesiuuuu and others added 3 commits May 28, 2026 15:00
Unity 6 moved tk2d sprite types to TeamCherry.TK2D.dll and video player
types to TeamCherry.Cinematics.dll. Mods compiled against the old API
expect these types in Assembly-CSharp, causing TypeLoadException at runtime.

- PrePatcher now injects ExportedType forwarders from TeamCherry.TK2D and
  TeamCherry.Cinematics into the patched Assembly-CSharp.dll
- New --mmhook mode in PrePatcher injects forwarders from MMHOOK_TeamCherry.*
  into MMHOOK_Assembly-CSharp.dll for On./IL. hook backward compat
- PostBuild target runs HookGen for TeamCherry.TK2D and TeamCherry.Cinematics,
  then patches MMHOOK_Assembly-CSharp with the resulting forwarders

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Unity 6 replaced the BinaryFormatter-encrypted save format with plain
UTF-8 JSON. The old LoadGame override manually handled decryption and
BinaryFormatter deserialization; this is now handled entirely by the
vanilla Platform layer.

Remove the custom GetSaveStatsForSlot override (vanilla handles JSON
correctly) and simplify LoadGame to call orig_LoadGame after hooking
mod save data, removing ~200 lines of now-dead BinaryFormatter code.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Rigidbody2D.velocity -> linearVelocity (HeroController)
- Object.FindObjectOfType -> FindFirstObjectByType (UIManager, GameCameras)
- MenuButtonList.RecalculateNavigation: null-conditional to prevent NRE
  when menuButtonLists is not yet initialized
- Language.Language moved to TeamCherry.Localization in Unity 6:
  add backward-compat stub in Assembly-CSharp namespace and update
  internal usages to TeamCherry.Localization.Language directly

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@leesiuuuu
Copy link
Copy Markdown
Author

CI failure explanation

The CI build fails because hk-binary-archives for 1.5.78.11833 is missing several assemblies that were added in Unity 6:

  • TeamCherry.Localization.dll
  • TeamCherry.TK2D.dll
  • TeamCherry.Cinematics.dll

These are new Unity 6 assemblies that the game ships alongside Assembly-CSharp.dll. The binary archive likely contains the main managed folder but does not include these new TeamCherry-namespaced DLLs.

To unblock CI, the hk-binary-archives 1.5.78.11833 entries for each platform would need to include these three assemblies in the managed archive. The DLLs are located in the game's hollow_knight_Data/Managed/ directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant