Search Unity

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:
    8,282
  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:
    8,282
    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:
    8,282
    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:
    8,282
    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:
    8,282
    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:
    8,282
    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.
     
  13. kaushik_pba

    kaushik_pba

    Joined:
    Mar 19, 2018
    Posts:
    12
    Hi @karl_jones ,
    I am doing the same thing and I am able to load scene from Addressable built from sub project.
    But the localization is not working. It is complaining about missing Table Collection.
    This is what my subproject settings looks
     

    Attached Files:

  14. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,282
  15. kaushik_pba

    kaushik_pba

    Joined:
    Mar 19, 2018
    Posts:
    12
    I am using this code to load Addressable catalog and then load scene:

    AsyncOperationHandle<IResourceLocator> handle = Addressables.LoadContentCatalogAsync($"{Application.dataPath}/../Games/Arcadia/catalog_v1.json", true);
    yield return handle;

    yield return Addressables.LoadSceneAsync("Arcadia");
     
    Last edited: Jan 12, 2024
  16. kaushik_pba

    kaushik_pba

    Joined:
    Mar 19, 2018
    Posts:
    12
  17. kaushik_pba

    kaushik_pba

    Joined:
    Mar 19, 2018
    Posts:
    12
    I can share simple test project if required.
     
  18. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,282
    Yes a test project would help.
     
  19. kaushik_pba

    kaushik_pba

    Joined:
    Mar 19, 2018
    Posts:
    12
    Hi this is the simple test project.
    It has two unity projects MainProject and ProjectA.
    ProjectA is inside submodules folder in MainProject folder.
    MainProject has MainScene with a button to launch ProjectA.
    In ProjectA I have created ProjectA Addressable profile to export addressable to a particular folder.
    You will have to update ProjectA profile variable to point to correct location.
     

    Attached Files:

    karl_jones likes this.
  20. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,282
    Hi,
    I took a quick look at the project but I just wanted to check something.
    Are you having the issues in the editor or player?
    If its the editor you need to make sure you have "Use Existing Build" set as the addressables play mode, we dont support multi projects in the other modes.
     
  21. kaushik_pba

    kaushik_pba

    Joined:
    Mar 19, 2018
    Posts:
    12
    For now testing on editor.
    I did change the settings to use "Use Existing Build" but still not working.

    So my MainProject is able to load ProjectA scene but not able to find Tables. I think I am missing some settings.

    What I want to achieve is to be able to load catalog from any location [local/remote] in the editor.
     
    Last edited: Jan 16, 2024
  22. kaushik_pba

    kaushik_pba

    Joined:
    Mar 19, 2018
    Posts:
    12
    Hi @karl_jones were you able to reproduce issue on your end?
     
  23. kaushik_pba

    kaushik_pba

    Joined:
    Mar 19, 2018
    Posts:
    12
    Nevermind finally found out that everything is working Its just that in editor mode it is complaining about missing table collection but it did work
     
    karl_jones likes this.
  24. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,282
    Sorry, not had a chance to look at this. It sounds like it was the issue I mentioned. Are you adding the manifest in the editor and using Use Existing build? It will still say the error in the inspector/table editor though.
     
  25. kaushik_pba

    kaushik_pba

    Joined:
    Mar 19, 2018
    Posts:
    12
    It is working in Main Project regardless whether I select Use Asset Database or Use Existing build
     
    karl_jones likes this.