Page 1 of 1

Image in alert and multi platform support

Posted: Fri Dec 22, 2017 9:13 am
by mgregoirelds
Hello,

I'm currently in the process of implementing tutorial steps in my game. What I thought of is to launch an Alert, for a few seconds, such as "To sprint, press on X button to make your hero go faster" when hitting an Alert Trigger. I've been able to make it work with localization using a Localized Text Table. However, I have two questions:

1) Is it possible to replace a value in the string for an image? As an example, on Xbox One, to run we use 'X' while on PS4, the 'X' button is replaced by the 'Square' button. I think it is a requirement by the platform to display an image of the button on those platforms instead of writting in text 'X' button and 'Square' button.

2) What would be the best way for me to handle platform handling? I was thinking of having a GameObject with a BoxCollider2D, two Alert Trigger scripts (one for Xbox One, one for PS4) and one custom script implementing the OnTriggerEnter2D function what will call OnUse on the valid Alert Trigger script based if UNITY_PS4 or UNITY_XBOXONE is defined. Would that make sense? Do you see a better solution?

Thanks!

Re: Image in alert and multi platform support

Posted: Fri Dec 22, 2017 9:39 am
by Tony Li
mgregoirelds wrote: Fri Dec 22, 2017 9:13 am1) Is it possible to replace a value in the string for an image? As an example, on Xbox One, to run we use 'X' while on PS4, the 'X' button is replaced by the 'Square' button. I think it is a requirement by the platform to display an image of the button on those platforms instead of writting in text 'X' button and 'Square' button.
Can you use Text Mesh Pro? It's free now. You can embed images in text fairly easily. You can also embed images in text with Unity UI using the <quad> rich text tag, but it's not quite as friendly to do.
mgregoirelds wrote: Fri Dec 22, 2017 9:13 am2) What would be the best way for me to handle platform handling? I was thinking of having a GameObject with a BoxCollider2D, two Alert Trigger scripts (one for Xbox One, one for PS4) and one custom script implementing the OnTriggerEnter2D function what will call OnUse on the valid Alert Trigger script based if UNITY_PS4 or UNITY_XBOXONE is defined. Would that make sense? Do you see a better solution?
That would work. Alternatively, you could set a Dialogue System variable based on the platform:

Code: Select all

DialogueLua.SetVariable("Platform", "PS4");
Then check that variable in the Alert Triggers' Condition sections. This way you don't need to write any scripts after setting the Platform variable.

Re: Image in alert and multi platform support

Posted: Fri Dec 22, 2017 9:53 am
by mgregoirelds
Thanks a lot, I will look at Text Mesh Pro. Great tips as always.

Re: Image in alert and multi platform support

Posted: Fri Dec 22, 2017 2:22 pm
by Tony Li
Glad to help! BTW, there's an updated Text Mesh Pro Support package on the Dialogue System Extras page. It's also in version 1.7.7, but 1.7.7 isn't available on the Asset Store yet.