Search Unity

Works in editor but not in build - addressables build done

Discussion in 'Localization Tools' started by dan_soqqle, Apr 10, 2022.

  1. dan_soqqle

    dan_soqqle

    Joined:
    Feb 2, 2022
    Posts:
    114
    Hi,

    *edit* this is now confirmed as a bug, feel free to upvote for the bug to be fixed thanks!:
    https://issuetracker.unity3d.com/is...ayed-in-the-play-mode-when-using-localization


    The localization works well on editor. but when i try to do it on build on an actual Iphone device I get the below. On the screen, the text becomes blank, probably because no font asset is found. However, it seems to only happens after i do an Addressables loadScene.

    Please assign a Font Asset to this Text (TMP) gameobject.
    TMPro.TextMeshProUGUI:Rebuild(CanvasUpdate)
    UnityEngine.UI.CanvasUpdateRegistry:performUpdate()
    UnityEngine.WillRenderCanvases:Invoke()

    I confirm that i have done the addressables 'New build'. Many times in fact. I also have done the Addressables Analysis - no errors.

    Any ideas?

    upload_2022-4-10_23-6-19.png

    upload_2022-4-10_23-28-27.png
     
    Last edited: Apr 14, 2022
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,281
    Hi,
    I have not seen this issue before. Could you please file a bug report so we can investigate?
     
  3. dan_soqqle

    dan_soqqle

    Joined:
    Feb 2, 2022
    Posts:
    114
    Hi Karl, thanks for responding. Submitted https://fogbugz.unity3d.com/default.asp?1419084_cjlbvkiprbq37i85 (Case 1419084). I created a whole new app within nothing but two scenes, two tmp_texts, two buttons, addressables/localization, and is able to replicate the problem.

    I also added a screenshot on how it looks on unity vs the actual app. It's a bit strange, the initial scene is fine but after addressables loading, all the text goes blank.

    (Also i dont know why but my phone is in Chinese yet the app dosen't change anything, on scene1).

    upload_2022-4-11_9-37-32.png
     

    Attached Files:

  4. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,281
    Ah great, can you submit this with a bug report? https://unity3d.com/unity/qa/bug-reporting
     
  5. dan_soqqle

    dan_soqqle

    Joined:
    Feb 2, 2022
    Posts:
    114
    Hi Karl, sorry not sure if i was doing it correctly. I looked at the link you provided and followed the steps. I submited the bug in unity -> Help->Report a Bug in the menu


    Can i also ask a stupid question, i saw in some threads there were samples but i couldn't find any link. Is there a demo / or sample repository/scene somewhere which I can take a look to see?
     
    Last edited: Apr 14, 2022
  6. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,281
    Yes that's correct.
    The samples are in the package manager window under the localization package details. There is a section near the bottom of the panel
     
  7. dan_soqqle

    dan_soqqle

    Joined:
    Feb 2, 2022
    Posts:
    114
    Found it! Maybe could be mentioned in the documentation (maybe in the installation notes!).
     
    karl_jones likes this.
  8. dan_soqqle

    dan_soqqle

    Joined:
    Feb 2, 2022
    Posts:
    114
    Hi, I spent almost two days trying to figure this out - to no avail. It appears it's a problem even with a completely new project and just a single scene with 1 text, 1 string table key. The localization doesn't get picked up on ios build. (unrelated to loadSceneAsync)

    I can confirm that the SelectedLocaleAsync picks up a locale: Chinese (Simplified) (zh-Hans). But the error is seen in xcode: Please assign a Font Asset to this Text (TMP) game object. I think, as a result, nothing is picked up, and neither the English nor Chinese text is not picked up. Addressables: 1.19.17, Localization: 1.2.1, Unity 2023.3.27f1:

    It's really weird. It works with the sample "Language Selection UGUI", also with just 1 text string. I checked file by file (addressables settings, localization settings, fonts, localization tables, scene control), and even the addressables, localization version. But the same setup dosen't work with a completely new project.

    There's literally nothing much to set up: localization locales (selector, identifier), string table, scene control, creating TMP font asset, adding it in the Chinese active locale. (did exactly the same in both the sample repo and a new repo). Confused :/

    Giving up for now.. and wondering why no one has had this issue. I created another bug report (Case 1419539) because it's a different description than the earlier one.
     
  9. dan_soqqle

    dan_soqqle

    Joined:
    Feb 2, 2022
    Posts:
    114
    Hi Karl, I was wondering if there might be any workaround, I am unable to get any translation at all working, even if it's just 1 string and nothing else in the entire code. The error was also replicated by QA.

    Unfortunately, I have some client pilots upcoming, and I don't any workaround for this.

    Bug is here https://unity3d.atlassian.net/servicedesk/customer/portal/2/IN-2140
     
  10. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,281
    Hmm. I dont seem to have permission to view your bug report (IN-2140). We are in the process of changing bug tracking systems so it could be that. Ill ask them. I was able to look at 1419539.

    I dont see any problems with 1419539. I dont have access to an iOS device to test but I could use the device simulator, does the error reproduce for you when using the xcode device simulator?
     
  11. dan_soqqle

    dan_soqqle

    Joined:
    Feb 2, 2022
    Posts:
    114

    Attached Files:

  12. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,281
    Ah thanks, ill try and take a look tomorrow.
     
  13. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,281
    Hey! So after spending some time I can now say this is indeed a Localization package bug.
    The GameObjectLocalizer works by applying changes to the target object using JSON. When applying changes to a Unity Object reference we need to apply the reference by its instance id.
    E.G if the object has id 3276 then the font json would look like:

    "m_fontAsset" : {
    "instanceID" : 3276
    }

    The problem is that in earlier versions of Unity (before 2022.2) this property name was actually different in the player and would not work, instead we needed to use ".m_FileID" in the player, not "instanceID". I reported this and it was subsequently fixed in 2022.2. We added a workaround:

    Code (csharp):
    1. #if UNITY_EDITOR || UNITY_2022_2_OR_NEWER
    2. const string instanceIdField = ".instanceID";
    3. #else
    4. const string instanceIdField = ".m_FileID";
    5. #endif
    However, this was only applied to localized assets(assets in an Asset table), not those that were local(using a UnityObjectProperty). It looks like we had hardcoded ".instanceID" for local objects.
    The reason QA thought it was fixed in the latest release was down to this fix in 2022.2.

    I'll get it fixed in the package for the next release, thanks for your help.

    For now you can work around this by not using local assets, use assets in Asset tables instead. This means you need to create an empty asset table and assign it to the Asset Table field in the Scene Controls. Now changes will be stored in the asset table instead of the component. https://docs.unity3d.com/Packages/c...yVariants.html#configuring-the-scene-controls
    You will need to remove and recreate the existing variants you have.
     
    Last edited: May 17, 2022
  14. dan_soqqle

    dan_soqqle

    Joined:
    Feb 2, 2022
    Posts:
    114
    Hi there sorry, i can't find out how to create an asset table? could you point me in the right direction?

    Glad I was able to help! Altho I'm wondering why others did not face this problem
     
  15. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,281
    Last edited: May 18, 2022
  16. dan_soqqle

    dan_soqqle

    Joined:
    Feb 2, 2022
    Posts:
    114
    It works on asset table :) Although I'm quite unclear.. if it works on asset table, why would I then use string table?
     
  17. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,281
    Assets go into the asset tables and the strings go into the string tables. So you need both.
    We are working on changes in 2.0 so there will be 1 universal table type so in the future it can just be 1 table but that's far away now.
     
  18. dan_soqqle

    dan_soqqle

    Joined:
    Feb 2, 2022
    Posts:
    114
    I still can't get it to work properly :/ Neither the traditional or simplified Chinese characters seems to populate correctly, even when using Assets. The characters don't even show squares, just missing characters.

    Do you have any tips? I did try a completely new project with 2021 version instead. Though it looks like it works there.. Should I try with an updated unity version?

    upload_2022-5-19_22-40-56.png
     

    Attached Files:

  19. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,281
    Those squares indicate that the font is missing the character. If its working in 1 version but not the other then that does seem to indicate there's a bug but it may have been fixed in the newer versions. Feel free to file a bug report so we can look into it.
     
  20. trefun

    trefun

    Joined:
    Dec 6, 2020
    Posts:
    1
  21. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,281