Dynamically insert controls into strings

More
7 years 9 months ago - 7 years 9 months ago #1562 by Skarz3D
Hello!

Is it possible to have "placeholder tags" in a string that is updated at runtime? My purpose for this is to have strings that display the correct key/button in the string when the game is running (because the user can remap keys, plug in a controller, etc).

Example String: Please press [USE ACTION] to use the item.

PC Output: Please press E to use the item.
XBox Output: Please press (A) to use the item.

Second question - if the above is possible, can it also insert images in-line (so in the above example it would show a picture of the A button instead of having text).

Thanks in advance for pointing me in the right direction!

Cheers,

Scott
Last edit: 7 years 9 months ago by Skarz3D.

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

More
7 years 9 months ago - 7 years 9 months ago #1564 by Frank

Is it possible to have "placeholder tags" in a string that is updated at runtime?


There is a Parameters System that I'm releasing in the next version, that allows getting variables from your code and replacing specific tags with the value of the variable.
e.g. "The winner is {PLAYER_WINNER}"
And the value of PLAYER_WINNER is set dynamically from your code.
However that system is not available in the latest release, it should be in 2.6.7a3.

In the meantime, there is a way to implement what you need by using Callbacks:
inter-illusion.com/assets/I2LocalizationManual/Callbacks.html

Just add a script with a callback function to your label and reference that function in your Localize component "On Localize Call" section.

My purpose for this is to have strings that display the correct key/button in the string when the game is running (because the user can remap keys, plug in a controller, etc).


Also, I'm working in a feature that is designed for that specific case. Currently the plugin allows specifying different translation for PC and Touch device, so that you could show "Click on the button" or "Tap the button" depending on the device you are on.
However, the current system is only for Touch and PC, I'm extending it to support any input system (even custom). (e.g. PC, Touch, XBoxController, Gyro, VR, etc)

The implementation of this Input Specialization feature is scheduled for the final 2.6.7 or the first alphas of 2.6.8

can it also insert images in-line (so in the above example it would show a picture of the A button instead of having text).


The plugin doesn't render the text directly, so what it can do is constrained by the renderers you are using (e.g. Unity UI Text, TextMeshPro, NGUI Label, etc)

In all of them, you can use rich-text tags to add the images. Or you could just bake the button images into a custom font and use that for rendering the texts and images.
TextMeshPro sprites in text:

using custom fonts in NGUI: www.tasharen.com/forum/index.php?topic=406.0

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
Last edit: 7 years 9 months ago by Frank.

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

More
7 years 9 months ago #1565 by Skarz3D
Awesome response, thank you for the information! We'll look into your suggestions.

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

Time to create page: 0.282 seconds
Template by JoomlaShine