Problems settings target On Localize call

More
4 years 5 months ago - 4 years 5 months ago #829 by cedtat
Hello,

I am using your plugin since two days and loving it.
I have done basic localization, now digging into parameters.

I would prefer use:
string text = I2.Loc.ScriptLocalization.Get("MyKEY");
But I read that it was not working properly with RTL & Arabic

Here comes the problem: when using callback, I drag my gameobject in the target and I don't see my method (which is public in a monobehavior public class, but not attached to localized object). I see other methods from NGUI scripts I think, which are attached to the gameobject but nothing from my script. Any idea ?

Thanks for your help,
Cedric
Last edit: 4 years 5 months ago by cedtat.

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

More
4 years 5 months ago #830 by Frank

I would prefer use:
string text = I2.Loc.ScriptLocalization.Get("MyKEY");
But I read that it was not working properly with RTL & Arabic


A few versions ago, an optional parameter was added to the ScriptLocalization.Get so that the returned text get fixed for RTL.
The signature of that method is
public static string Get( string Term, bool FixForRTL = false );

So by calling the method with a true as the second parameter it will fix the text (Only if the language is RTL) So, its safe to always call it with true (i.e. English and other non RTL will ignore that last parameter)
string text = I2.Loc.ScriptLocalization.Get("MyKEY", true);

Here comes the problem: when using callback, I drag my gameobject in the target and I don't see my method (which is public in a monobehavior public class, but not attached to localized object). I see other methods from NGUI scripts I think, which are attached to the gameobject but nothing from my script. Any idea ?


The target object for the callback is the object that contains the script with the function that you will use as a callback.
Thats why your method should be added to a monobehavior and attached to that object.

If you want your Callback to be global, then create an object in your scene with that script, and then assign that same object to every Localize component that should use the Callback function.

In the UnityStandard example scene, I added the callback method to an script named CallbackNotification.cs and attached that script to any object. Then I assigned as the target, the object that has it attached.

Hope that helps
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
4 years 5 months ago #831 by cedtat
Thank you for your quick reply.
I will use the GET method since I was doing something similar with a dictionnary, it will be integrated in seconds with a search/replace.

I am a new happy client B)
Cheers,
Cedric

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

More
4 years 5 months ago #832 by cedtat
Sorry I get back with "On Localize call" functionnality.

I have tried a few things, I think there is something missing or a bug.
When I put two scripts on a object and use this object as a target.
It only show me methods of the first script component. If I change the order by removeing the first one and adding it again so that it appears at the end, I know see methods of the other component script.

Hope I was clear.
I generally have to bind the controller of the scene to modify localization dynamically and the controller is not always the first component on the gameobject.

Best regards,
C├ędric

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

More
4 years 5 months ago - 4 years 5 months ago #833 by Frank
Hi,
I see what the issue is.
The idea is that you shouldn't drag to the Target the gameObject because otherwise it will take the first Monobehavior. Instead you should drag there the actual monobehavior you are interested in.
When the monobehavior is in the same object that has the Localize component, you just need to drag from the name of the script into the target slot.

However, when the controller is in a different object, it gets tricky as you will have to open two Inspector tabs and lock one.

To avoid that issue, I went to modified the Localize Inspector to look for ALL the monobehaviors in the target GameObject.
I'm attaching the changes. Just replace the file at I2\Localization\Scripts\Editor\Inspectors\LocalizeInspector.cs by the one in the zip.

File Attachment:

File Name: LocalizeInspector.zip
File Size:5 KB


Now you can just drag the gameObject into the target slot and you all public methods with no parameters from all monobehaviors in that GameObject will be listed.

BTW, This changes will also be added to version 2.6.0

Thanks,
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
Attachments:
Last edit: 4 years 5 months ago by Frank.

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

More
4 years 5 months ago - 4 years 5 months ago #834 by cedtat
Thank you Frank, this is working perfectly B)

PS: didn't knew that I could open two inspectors... great tip.
Last edit: 4 years 5 months ago by cedtat.

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

Time to create page: 0.178 seconds
Template by JoomlaShine