Search Unity

Question Localization package "sometimes" throws formatting exception

Discussion in 'Localization Tools' started by XIV_Dis, Jul 28, 2021.

  1. XIV_Dis

    XIV_Dis

    Joined:
    Mar 20, 2020
    Posts:
    9
    Hi everyone,
    Im having a little trouble here.
    The strange thing is code works but sometimes it throws formatting exception. I need to restart application when it starts to throw exceptions. Im assuming that when i set the string reference it tries to parse immediately but there is no giving argument yet and because of that it is throwing the exception. But on the other hand it is working also. It happens sometimes. I couldnt understand why it happens and how i can workaround. I tried to create new LocalizeStringEvent and set its StringReference and arguments but its giving the same result.

    Code (CSharp):
    1.  
    2.     public void SetText(LocalizedString localizedString, object argument)
    3.     {
    4.         if (lse == null)
    5.             lse = GetComponent<LocalizeStringEvent>();
    6.  
    7.         lse.StringReference = localizedString;
    8.         lse.StringReference.Arguments = new[] { argument };
    9.     }
     
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,292
    Yes setting the arguments will do that at the moment. We have stopped that in the next release. One way to fix this is to disable the LocalizeStringEvent component whilst making changes and then reenable it.
     
    XIV_Dis likes this.