Trouble with using global parameters

More
8 years 1 month ago #1871 by Hebson
Hi there, I recently updated to latest plugin to setup some much needed parameters. I looked at the examples and followed (I think) the tutorial/documentation but can't seem to get them working.

I copied the GlobalParametersExample, attached it to a game object, but the GetParameterValue function does not called. Additionally, in game, the term I am trying to setup "Age: {[CHAR_AGE]}" is show in game exactly as "Age: {[CHAR_AGE]}". There seems to be no attempt to replace the parameter.

Any suggestions on how to fix this? I also tried local parameters too without success.

Thanks,

Ally

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

More
8 years 1 month ago #1872 by Frank
Hi,

Things to check:
- If you added a copy of the GlobalParametersExample.cs to an object, verify that the object is enabled.
- The parameters are not called, if there the localization is not found: Can you verify that the localization is been set.
e.g. If you have the term PARAM_EXAMPLE and english is "Age: {[CHAR_AGE]}" and spanish is "Edad: {[CHAR_AGE]}", check that switching languages also changes the text.
- If you use LocalParameters, then that script needs to be in the GameObject with the Localize component.

Can you post or send me the modified script you are using, maybe I can spot something from there!

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
8 years 1 month ago #1876 by Hebson
hi! So the language/localization is being set. I did as you suggested and we're definitely are seeing the same issue still. GlobalParametersExample.cs is on an active object.

The parameters we're looking to set all are all handled in code currently so thinking the local variables will not work as we have no localization component attached. Our code looks like, for example:
pugDetails.text = I2.Loc.ScriptLocalization.Get("AgeText")

I'd love to be able to send you an example scene/demo but I'm on a commercial project which prohibits this.

Any other suggestions?

Cheers,

Ally

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

More
8 years 1 month ago #1878 by Frank
Ahhh, that makes sense now.

The issue is that ScriptLocalization.Get(xxx) doesn't add the parameters. Instead, you have to call LocalizationManager.ApplyLocalizationParams after the .Get call.
        string text =I2.Loc.ScriptLocalization.Get("AgeText")
	LocalizationManager.ApplyLocalizationParams (ref text, null);
        pugDetails.text = text;

that was done to allow the possibility of doing your own parsing before the parameters were added (it is used in the Localize component, to allow the LocalizationCallback to run before the parameters).
Nonetheless, I agree, its not too intuitive. So, I will enable the parameters when you call ScriptLocalization.Get, and have an extra parameter that could be set to false to avoid having the parameters applied! I think that will make more sense.

While I add that, you can call the ApplyLocalizationParams directly and it will work!
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
The following user(s) said Thank You: Hebson

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

More
8 years 1 month ago #1881 by Hebson
Ah, thanks! Will test this out tomorrow. I hacked together the following before I read your post...
pugDetails.text = I2.Loc.ScriptLocalization.Get("AgeText").Replace("{[CHAR_AGE]}", exampleIntVar)

... which does the trick but isn't exactly ideal.

Cheers,

Ally

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

Time to create page: 0.171 seconds
Template by JoomlaShine