Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Enter the 2020.2 Beta Sweepstakes for a chance to win an Oculus Quest 2.
    Dismiss Notice

Multiple ChangeHandlers on a LocalizedString

Discussion in 'Localisation Tools Previews' started by nicolasgramlich, Aug 13, 2020.

  1. nicolasgramlich

    nicolasgramlich

    Joined:
    Sep 21, 2017
    Posts:
    182
    Hey everyone,

    first of all, terrific package so far!

    I have one remaining issue before I can wrap up localization in my game.

    1. I have units in my game that have names.
    2. I have a Unit ScriptableObject that used to have just a string ("Knight") but now it's a LocalizedString. No problem so far.
    3. Everything is fine as long as the LocalizedStrings are used only "once at a time".
    4. The issue is when the string shows up multiple times at once. Say I have a list of units that have the name of the unit (see screenshot below), some of them are pointing to the same "Knight" LocalizedString, things start to break (as in not all Texts update) because LocalizedString only has a single ChangeHandler.

    It expresses itself like this usually:



    ... where only one of them (the last one) gets the changehandler callback called, because RegisterChangeHandler is not a list, but gets cleared as soon as you call RegisterChangeHandler again.

    What's the proposed pattern to have all of them resolve/update when the local is switched?

    I guess I could fire off one `public AsyncOperationHandle<string> GetLocalizedString(params object[] arguments)` per text? The downside is that it wouldn't automatically update when the locale is changed, which is what makes the ChangeHandler stuff so very useful :(

    Bonus question:
    Why is the `ChangeHandler` not a "List" and instead just a single reference that gets overwritten? Feels like a very useful thing to have it be able to "multiplex" :)

    Thanks,
    Nicolas
     
    Last edited: Aug 13, 2020
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    4,245
    Hi,

    Good question. At the time it was envisioned that it would be a LocalizedString with a single target however your use case makes a good argument for having multiple subscribers. I'll see if we can convert this into an event in time for the next release.
     
    nicolasgramlich likes this.
  3. nicolasgramlich

    nicolasgramlich

    Joined:
    Sep 21, 2017
    Posts:
    182
    First the Dark Theme, and then this response in the same day... :):):):):):):)

    Christmas is coming early!
     
    karl_jones likes this.
  4. nicolasgramlich

    nicolasgramlich

    Joined:
    Sep 21, 2017
    Posts:
    182
    @karl_jones
    Replaced LocalizedString RegisterChangeHandler and ClearChangeHandler with the event StringChanged


    Is this what I think it is? :eek::eek::eek:
     
    karl_jones likes this.
  5. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    4,245
    :)
    Yes just on time!
     
  6. nicolasgramlich

    nicolasgramlich

    Joined:
    Sep 21, 2017
    Posts:
    182
    Awesome! How do you feel like helping out the unity.animations team? ;) Haha j/k

    Works great so far!
     
    karl_jones likes this.
  7. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    4,245
    Haha I help out a lot of teams :D
    Is there something in particular you need with animation?
     
    BelkinAlex likes this.
  8. nicolasgramlich

    nicolasgramlich

    Joined:
    Sep 21, 2017
    Posts:
    182
    Just a teensy, tiny thing. URP support and updated samples :) It's been >6 months since we've been "promised" URP support and the samples haven't been updated ever since. We all understand that things tend to take longer than anticipated, but the lack of updates around this package is somewhat saddening.

    https://github.com/Unity-Technologies/Unity.Animation.Samples/issues/1#issuecomment-584739445
     
    BelkinAlex likes this.
  9. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    4,245
    I spoke to the team. They had put some of the sample development on hold due to code churn. Now that some pieces have landed they can resume updating the samples and expect to be able to deliver an updated version towards the end of September.
     
  10. nicolasgramlich

    nicolasgramlich

    Joined:
    Sep 21, 2017
    Posts:
    182
    Thanks!!! I really appreciate the follow up!
     
    cdm456852, karl_jones and thelebaron like this.
unityunity