Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Using Localization inside AssetBundle Scene

Discussion in 'Localization Tools' started by StarCoop, Jun 27, 2023.

  1. StarCoop

    StarCoop

    Joined:
    Nov 26, 2016
    Posts:
    44
    Hello guys,
    I am creating Content-Scenes as Asset Bundles in a separate Unity-Project (Project A) and we started using the Unity Localization for handling localization inside the AB.
    The AB gets loaded into another project (Project B) as a Scene and gets "played" there. Unfortunately I've realized that the Localization does not work after loading the AB - The Tables are not available.

    upload_2023-6-27_16-2-27.png

    This is a screenshot of the inspector of the loaded AssetBundle. As you can see the Table Collection is empty.
    I currently cannot wrap my head around how to approach this. From my understanding when im trying to access the Localization via LocalizationSettings it will get the LocalizationSettings of my Project-B which loads the AB but not the LocalizationSettings in the AB itself (from Project A).
    So I need my Localization Tables (String, Asset) written into the AB itself and the AB should also only use the Localization from the AB.
    If there is anyone who could point me to the right direction would be greatly appreciated.

    Best regards,
    Phil
     
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,846
  3. StarCoop

    StarCoop

    Joined:
    Nov 26, 2016
    Posts:
    44
    Let's say I create addressables out of my secondary project and import the addressables (with the String / Asset Tables from the Localization) into my primary Project. To me it's still unclear how my AB will use the String / Asset Tables inside the Addressable Catalog while I try to call it via LocalizationSettings. Do I need to announce the Tables to the Localization in the Primary Project?
     
  4. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,846
    The string table and entry information will be stored in the components. You won't be able to see the information in the inspector because the assets are in a different project but you will be able to load them at runtime providing the addressables data is included.
     
  5. StarCoop

    StarCoop

    Joined:
    Nov 26, 2016
    Posts:
    44
    Hello Karl, thanks for your reply.
    I've set up my Adressables inside the AB to be packed within the AB. Therefore from my understanding the addressable data (including the Localization tables) should be available. How would I load and assign the Tables to the Localization in the Viewer Project so that my AssetBundle can be localized? Since the LocalizeStringEvent-Component is empty, do I need to re-initialize them at runtime after loading the AssetBundle?
     
  6. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,846
    We don't support authoring in the editor when the localization data is in another project. So you won't be able to use the editors to set strings, you can still assign them, via script and they will work providing you set up the project to load the localization data from the other project. If you examine them in the inspector you will not get any useful information, it can not resolve the names or show the data as its not in the project. That doesn't mean it wont work at runtime though.
    In the screenshot you can see it does have the table guid assigned, so when you enter playmode and are using addressables then it should work.
    If you are doing this in the editor then make sure the addressables play mode is set to use excisting build.
     
  7. StarCoop

    StarCoop

    Joined:
    Nov 26, 2016
    Posts:
    44
    Hello Karl,
    I don't need to author the localization data once the Asset Bundle is built. I also don't need to have information shown in the inspector, since in the end its a built Windows Application. I see that it is missing a Table Collection with a certain GUID. So what I think needs to be done is to assign the Table Collection to the Localization Settings at runtime? Do I have to Load the Addressables from the AssetBundle first and then get the Table Collection out of that? I've set the Play Mode in our Viewer Project (which loads the AssetBundle as a Scene) to use existing Build but still the TableCollection is missing.
     
  8. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,846
    The warning about the missing table GUID is just an editor issue because the localization data is not in the project.
    When you run the game it will request the table with that GUID from addressables and then it should then be able to find it from the other projects' data, providing the table with that GUID exists in the data.
    You should only need to add the built addressable data from the project that contains the localization assets for it to work
    https://docs.unity3d.com/Packages/com.unity.addressables@1.21/manual/MultiProject.html

    So:

    1. Build Addressables for the project with localization
    2. In the other project link against that data via addressables
    3. It should now show the localized values. If you get some errors then please post them, the warnings in the previous screenshot can be ignored. The order things are done should not matter.
     
  9. StarCoop

    StarCoop

    Joined:
    Nov 26, 2016
    Posts:
    44
    Hello Karl,
    I've managed to make it work by loading the Addressable Catalog before loading the Asset Bundle.

    After a while I'm now encountering the following issue:

    upload_2023-7-4_14-0-15.png

    I'm not able to load the catalog anymore. Also every time I click into the addressable group window this error appears - I see no more addressable groups or any addressable at all until i restart the Editor. I'm using Addressables 1.20.5 in both projects aswell as Localization 1.4.3.

    In my Viewing project the following error appears:

    upload_2023-7-4_14-0-57.png

    I've tried updating the Addressable package to no avail. It looks like the Localization Addressable package (which I believe is created within the Localization System) is buggy or somehow erroneous.

    Best regards,
    Phil
     
  10. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,846
    Could you please file a bug report so we can investigate?
    https://unity3d.com/unity/qa/bug-reporting
     
  11. StarCoop

    StarCoop

    Joined:
    Nov 26, 2016
    Posts:
    44
    Hello Karl,
    I've managed to get the localization package running again by reimporting the whole project.
    After loading the localization via the addressable catalog everything seemed to look fine until I tried changing the language. For some reason my second locale (DE) is not detected.
    In Project A I have a Localization Settings with Locale DE and EN. In Project B i also have DE and EN locales in my settings.
    When I start Project A my Settings look like this:

    upload_2023-7-20_14-42-21.png

    When I'm loading my AB-Scene from Project B (via Content Catalog) for reasons unknown to me the German locale identifier (DE) changes to EN in the runtime. If I manually change the identifier back to DE (in the runtime) the missing locale is detected and language changing works fine.

    This is my default group inside Project B where the localization stuff resides:

    upload_2023-7-20_14-45-10.png

    Should I have the locales and Localization Settings from Project B in my Catalog? If so, do I need to manually load in the localization settings in project A?

    Best regards,
    Phil
     
  12. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,846
    It sounds like you may be loading the same locales multiple times if they are in both projects. You should only need the localization settings and locales in the 1 project, you should not need them in both. Try removing them and see if it works.