OnLocalize callback not firing

More
7 years 5 days ago - 7 years 5 days ago #2647 by enghoff
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: 7 years 5 days ago by enghoff. Reason: more details added

Please Log in or Create an account to join the conversation.

More
7 years 4 days ago #2649 by Frank
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

Please Log in or Create an account to join the conversation.

More
7 years 4 days ago #2650 by enghoff
Thanks, that's definitely a better solution than adding a dummy GUI Texture, which became my workaround B)

Please Log in or Create an account to join the conversation.

More
7 years 4 days ago - 7 years 4 days ago #2651 by enghoff
Regrettably it doesn't seem to resolve the issue :(
Last edit: 7 years 4 days ago by enghoff. Reason: typo

Please Log in or Create an account to join the conversation.

Time to create page: 0.194 seconds
Template by JoomlaShine