Skip to content

IL2CPP: Game crashes with TextMeshPro 1.4.0 support (Unity 2022.3.59f1) #770

@qweshka

Description

@qweshka

Environment

Game: Blue Protocol Star Resonance
Unity Version: 2022.3.59f1
TextMeshPro Version: 1.4.0
Plugin Version: XUnity.AutoTranslator 5.4.6
BepInEx Version: 6.0.0-be.704 (IL2CPP)
Platform: Windows 10 64-bit

Issue

The game crashes when EnableTextMeshPro=True is set in the configuration. Settings.cs:234 The game runs successfully with all text frameworks disabled, but enabling TextMeshPro causes immediate crashes.

Logs

The plugin loads successfully and detects TextMeshPro 1.4.0, but fails to hook TMP_Text.SetCharArray:

[Info   :XUnity.AutoTranslator] Version of TextMesh Pro: 1.4.0.  
[Warning:  HarmonyX] AccessTools.Method: Could not find method for type TMPro.TMP_Text and name SetCharArray and parameters (Il2CppInterop.Runtime.InteropTypes.Arrays.Il2CppStructArray<int>, int, int)  
[Warning:XUnity.AutoTranslator] Could not hook 'TMP_Text_SetCharArray_Hook3'. Likely due differences between different versions of the engine or text framework.  
[Info   :XUnity.AutoTranslator] Loaded XUnity.AutoTranslator into Unity [2022.3.59f1] game.

After this, the game crashes during initialization.

Root Cause

The plugin attempts to hook TMP_Text.SetCharArray with parameters (Il2CppStructArray, int, int) TextMeshProHooks.cs:341-354 , but this method signature doesn't exist in TextMeshPro 1.4.0. While the plugin gracefully handles this specific hook failure, one of the other TextMeshPro hooks TextMeshProHooks.cs:21-39 appears to cause a critical error in IL2CPP that crashes the game.

Workaround

Setting EnableTextMeshPro=False allows the game to run, but prevents translation of TextMeshPro UI elements. HooksSetup.cs:108-116
Request

Could you please add support for TextMeshPro 1.4.0 in IL2CPP builds? This is a very old version of TextMeshPro, but it's being used in a commercial game (Blue Protocol Star Resonance). The current hook implementations TextMeshProHooks.cs:301-377 appear to target newer TextMeshPro versions and are incompatible with 1.4.0's API.

Thank you for maintaining this excellent plugin!

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