Skip to content

Add localization support and language settings UI - #117

Open
StartNight wants to merge 2 commits into
AnyRPG:masterfrom
StartNight:feature/localization-ui
Open

Add localization support and language settings UI#117
StartNight wants to merge 2 commits into
AnyRPG:masterfrom
StartNight:feature/localization-ui

Conversation

@StartNight

Copy link
Copy Markdown

Summary

This PR introduces the official Unity Localization package (com.unity.localization v1.5.12) along with Addressables (com.unity.addressables v2.11.1), providing core localization infrastructure, font fallback support, and a dedicated Language tab in the in-game Settings menu.


Key Changes

1. Package & Asset Configuration

  • Added com.unity.localization and com.unity.addressables to Packages/manifest.json.
  • Configured Addressable asset groups and schemas for localization data.
  • Added Localization Settings with English (en) and Simplified Chinese (zh-Hans) locales and String Tables.
  • Added Source Han Sans (SourceHanSansCN-Normal) font asset and configured TextMeshPro fallback font on LiberationSans SDF Custom Outline for seamless multi-language character rendering.

2. Core Architecture & UI

  • LocalizationManager: Added localization manager and registered it within SystemGameManager life cycle.
  • SystemLanguagePanel: Added a new window panel component that dynamically manages language buttons and syncs highlight states with the active Locale.
  • MainSettingsMenuPanel: Added a new "Language" tab navigation and sub-panel activation logic.
  • Prefabs: Updated MainMenuPanel and MainSettingsMenuPanel prefabs with the new Language button and sub-panel bindings.

How to Test

  1. Open the project in Unity and enter Play Mode from the Main Menu.
  2. Open Settings (or System Menu) -> click on the new Language tab.
  3. Switch between English and Chinese (Simplified):
    • Confirm the selected language button is properly highlighted.
    • Confirm localized UI texts and character rendering update accordingly.

@michaelday008

michaelday008 commented Aug 29, 2026

Copy link
Copy Markdown
Collaborator

This looks great! Unfortunately, my Unity is crashing trying to import some of the localization assets. I'll see if I can figure out what's wrong, but if you've seen this before and have any ideas, please let me know.

Start importing Assets/AnyRPG/Core/Content/Localization/Localization Settings.asset using Guid(80e9cb1cac9911646bf50cf5cae97f71) (NativeFormatImporter)
=================================================================
	Native Crash Reporting
=================================================================
Got a UNKNOWN while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

=================================================================
	Managed Stacktrace:
=================================================================
=================================================================
Crash!!!
SymInit: Symbol-SearchPath: 'C:/Program Files/Unity/Hub/Editor/6000.3.10f1/Editor/Data/Mono;.;D:\unity\projects\AnyRPGCoreLocalization;D:\unity\projects\AnyRPGCoreLocalization\Library\BurstCache\JIT;C:\Program Files\Unity\Hub\Editor\6000.3.10f1\Editor;C:\WINDOWS;C:\WINDOWS\system32;', symOptions: 534, UserName: 'anyrpg'
OS-Version: 10.0.0
C:\Program Files\Unity\Hub\Editor\6000.3.10f1\Editor\Unity.exe:Unity.exe (00007FF7DE660000), size: 290816 (result: 0), SymType: '-deferred-', PDB: '', fileVersion: 6000.3.10.24332
C:\WINDOWS\SYSTEM32\ntdll.dll:ntdll.dll (00007FFE42160000), size: 2514944 (result: 0), SymType: '-deferred-', PDB: '', fileVersion: 10.0.26100.8972

@michaelday008

Copy link
Copy Markdown
Collaborator

@StartNight
When I removed the referenced file (Assets/AnyRPG/Core/Content/Localization/Localization Settings.asset) and re-imported, there was no crash, but then I got this following warning, which is I think the root cause. As soon as I moved the file back, the open editor immediately crashed.

AnyRPG Shared Data is already a member of group Localization-String-Tables-English (UnityEditor.AddressableAssets.Settings.AddressableAssetGroup) but group Localization-Assets-Shared contained a reference to it.  Removing reference.
UnityEditor.AssetPostprocessingInternal:PostprocessAllAssets (string[],string[],string[],string[],string[],bool)

Here is what google suggested as the fix. I'm not sure if this makes sense to you

Step 1: Force Unity to Boot Without Triggering the Post-ProcessorClose Unity.Temporarily move Localization Settings.asset out of the project folder again so you can open the editor.Open the project in Unity 6000.3.10f1.Step 2: Clear the Conflicting Reference in the Addressables WindowSince you are in the editor, you can now safely manipulate the groups before they are parsed by the localization system.Open Window > Asset Management > Addressables > Groups.Locate the two groups mentioned in the warning:Localization-String-Tables-EnglishLocalization-Assets-SharedLook for the asset named AnyRPG Shared Data inside both of those groups.The warning indicates Unity tries to auto-remove it from Localization-Assets-Shared. To resolve this permanently, manually select AnyRPG Shared Data from the group it shouldn't belong to, right-click it, and choose Remove Addressable(s) (or drag it so it only natively exists in the correct group).Step 3: Run the Official Localization Addressables AnalyzersUnity provides built-in tools explicitly designed to fix data-corruption mismatches like this before you push to a public repository:In the Addressables Groups window, click on Tools > Analyzers (or Check for Modifications).Look for the Localization Analyzers block.Run the following rules:Check Localization String TablesCheck Localization Asset TablesThe analyzer will flag any duplicate structures or references that would break the dependency tree on a clean import. Click Fix Selected Rules.Go to File > Save Project to save these structural changes into your actual Assets/AddressableAssetsData/ configuration tracking files.Step 4: Verify and CommitClose Unity.Move your Localization Settings.asset file back to its proper home (Assets/AnyRPG/Core/Content/Localization/).Re-open Unity. Because you fixed the double-allocation layout inside the Addressables configuration, the editor will read the setup cleanly, won't trigger the on-the-fly removal warning, and will boot up successfully.Commit your modified AddressableAssetsData files to your Git repository.

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.

2 participants