Welcome, Guest
Username: Password: Remember me

TOPIC: OnLocalize callback not firing

OnLocalize callback not firing 6 months 15 hours ago #2647

  • enghoff
  • enghoff's Avatar
  • Offline
  • Junior Member
  • Posts: 20
  • Thank you received: 1
  • Karma: 1
I am attempting to follow the approach suggested in www.inter-illusion.com/forum/i2-localiza...ith-a-material-on-it to replace the main material on a Mesh Renderer, but I never see the callback firing.

My Unity components are configured as in the attached and the LocalizeRenderer class is defined as -
[RequireComponent(typeof(Localize))]
[RequireComponent(typeof(Renderer))]
public class LocalizeRenderer : MonoBehaviour
{
    public void OnLocalize()
    {
        Debug.Log("Localize");

        if (!string.IsNullOrEmpty(Localize.MainTranslation))
        {
            GetComponent<Renderer>().material.mainTexture = GetComponent<Localize>().FindTranslatedObject<Texture>(Localize.MainTranslation);
        }
    }
}

UPDATE: while tracing code execution through Localize.cs it would appear that the OnLocalize method terminates as it is not finding a target, which appears possibly inconsistent with the guidance that "even if the component doesn't show any target, it will execute the callbacks"

Any assistance in resolving issue would be much appreciated :)

Cheers,
Sigurd
Attachments:
Last Edit: 6 months 14 hours ago by enghoff. Reason: more details added
The administrator has disabled public write access.

OnLocalize callback not firing 6 months 3 hours ago #2649

  • Frank
  • Frank's Avatar
  • Offline
  • Administrator
  • Posts: 1081
  • Thank you received: 231
  • Karma: 68
Hi,
You are totally right, in the latest refactoring of the localize flow, that changed the way the Targets were detected and used, that behavior was changed accidentally.

To fix this issue, just move the "if" at line 130, to right before applying the RTL fix in line 157:

i.e. Move this: Assets\I2\Localization\Scripts\Localize.cs (line 130-131)
			if (!HasTargetCache() && !FindTarget())
				return;

to line 157
			}

			if (!HasTargetCache() && !FindTarget())
				return;

			bool applyRTL = LocalizationManager.IsRight2Left && !IgnoreRTL;

That way, even if there is no target, the callbacks are executed.
I will add this change to the latest beta as well.

Thanks for pointing that out!
Frank
Are you :-) Give I2L 5 stars!
Are you :-( Please lets us know how to improve it!
To get the betas as soon as they are ready, check this out
The administrator has disabled public write access.

OnLocalize callback not firing 6 months 2 hours ago #2650

  • enghoff
  • enghoff's Avatar
  • Offline
  • Junior Member
  • Posts: 20
  • Thank you received: 1
  • Karma: 1
Thanks, that's definitely a better solution than adding a dummy GUI Texture, which became my workaround B)
The administrator has disabled public write access.

OnLocalize callback not firing 6 months 1 hour ago #2651

  • enghoff
  • enghoff's Avatar
  • Offline
  • Junior Member
  • Posts: 20
  • Thank you received: 1
  • Karma: 1
Regrettably it doesn't seem to resolve the issue :(
Last Edit: 6 months 1 hour ago by enghoff. Reason: typo
The administrator has disabled public write access.
Time to create page: 1.695 seconds
Colors