Search Unity

Question [SOLVED] Can't copy Game Object Localizer to another TextMeshPro UI string

Discussion in 'Localization Tools' started by Klausbdl, Dec 4, 2022.

  1. Klausbdl

    Klausbdl

    Joined:
    Aug 12, 2013
    Posts:
    64
    I have two string with the same text that I tried to add the same localization key, but it's not working for the number 2 one. What's the best approach to this without needing to create another localization key nor resorting to a script?

    Captura de ecrã 2022-12-04 150446.jpg

    Text 1: has the original component and it updates the string
    Text 2: has a copy of the component as it is, but won't update the string
     
    Last edited: Dec 4, 2022
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,279
    Is the game object localizer referencing the correct target? Try changing the inspector to debug so you can see the target field.
     
  3. Klausbdl

    Klausbdl

    Joined:
    Aug 12, 2013
    Posts:
    64
    This is the debug inspector of the copied component to the second string with the same text. Where do you find this target field?
    Btw:
    Unity version 2021.3.15f1
    Localization package version 1.3.2
    upload_2022-12-4_16-26-58.png

    edit: note: only the "Instance ID" and "Local Idenifier in File" are different from the first string. The rest is the same
     
  4. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,279
    Its not showing it. Its part of the Tracked Object. You may need to edit the file TrackedObject.cs and remove the HideInInspector attribute over m_Target. Check that the target is not pointing to the wrong GameObject
     
  5. Klausbdl

    Klausbdl

    Joined:
    Aug 12, 2013
    Posts:
    64
    Thanks. Got it working by changing as follows:
    upload_2022-12-4_17-48-19.png

    I only came up with this problem because I couldn't manually set an UI text to use a table entry, but now I just figured it out!
    For anyone having the same problem setting an UI text to have a localization:
    1. Right click on right above the text field and click "Localize Property"
    upload_2022-12-4_17-53-5.png

    2. On the added component below, click on that dropdown. Because it doesn't automatically show up, you have to type in the key to set it. I was having trouble because of that, but now I don't need to copy and paste the component in the first place anymore.
    upload_2022-12-4_17-56-34.png
     
    karl_jones likes this.
  6. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,279
    Ah yes, this is a bug. We have a fix in the next release.
     
  7. AShim-3D

    AShim-3D

    Joined:
    Jul 13, 2012
    Posts:
    34
    The bug is still there. When do you plan to fix it?
    In any case, this is my fix:
    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEditor;
    3. using UnityEngine.Localization.PropertyVariants;
    4.  
    5. public static class FixTrackedObject {
    6.  
    7.     [MenuItem("Localization/Fix TrackedObject.Target")]
    8.     public static void Do()
    9.     {
    10.         foreach (var gameObject in Selection.gameObjects)
    11.         {
    12.             var localizer = gameObject.GetComponent<GameObjectLocalizer>();
    13.             foreach (var tracketObject in localizer.TrackedObjects)
    14.             {
    15.                 if (tracketObject.Target is MonoBehaviour monoBehaviour) {
    16.                     if (monoBehaviour.gameObject != gameObject) {
    17.                         var newTarget = gameObject.GetComponent(tracketObject.Target.GetType());
    18.                         if (newTarget != null)
    19.                             tracketObject.Target = newTarget;
    20.                         else
    21.                             Debug.LogError($"Selected object doesn't have {tracketObject.Target.GetType()} component");
    22.                     }
    23.                 }
    24.             }
    25.         }
    26.     }
    27. }
    28.  
     
  8. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,279
    What bug is this? I don't recall the one I was referring to in 2022 but it would have landed so this must be a different issue. Could you please file a bug report? https://unity.com/releases/editor/qa/bug-reporting