Search Unity

Question Arguments getting cleared OnEnable

Discussion in 'Localization Tools' started by CDF, Apr 15, 2021.

  1. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    1,311
    Inside LocalizeStringEvent, the OnEnable method calls RegisterChangeHandler, which in turn clears the StringReference arguments.

    This is causing issues for us when we set the StringReference arguments through code, then later an animator may turn on/off gameObjects that contain LocalizeStringEvent components.

    What happens is when the localized components become enabled again, the arguments are cleared, and the resulting string is incorrect.

    I would maybe suggest changing from:
    arg_changes.png
    to:
    arg_changes_fix.png

    Unless there's another way to prevent arguments from clearing?
     
    karl_jones likes this.
  2. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    1,311
    alternatively, maybe exposing m_FormatArguments as a public property would help to.
    So instead of setting StringReference.Arguments, we can set LocalizeStringEvent.FormatArguments

    sadly, that field is currently private :(
     
  3. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,299
    Hi,
    We have already fixed this, it will be in the next release.
    We made the same change as you suggested.
    We don't apply the argument if there is none.
     
    CDF likes this.
  4. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    1,311
    Awesome, thanks
     
    karl_jones likes this.