Image in alert and multi platform support

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
mgregoirelds
Posts: 106
Joined: Wed Aug 23, 2017 4:10 pm
Location: Canada

Image in alert and multi platform support

Post 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!
Unity 2022.3.17f1
Dialogue System 2.2.44.1
OpenAI Addon 1.0.12
User avatar
Tony Li
Posts: 22062
Joined: Thu Jul 18, 2013 1:27 pm

Re: Image in alert and multi platform support

Post 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.
mgregoirelds
Posts: 106
Joined: Wed Aug 23, 2017 4:10 pm
Location: Canada

Re: Image in alert and multi platform support

Post by mgregoirelds »

Thanks a lot, I will look at Text Mesh Pro. Great tips as always.
Unity 2022.3.17f1
Dialogue System 2.2.44.1
OpenAI Addon 1.0.12
User avatar
Tony Li
Posts: 22062
Joined: Thu Jul 18, 2013 1:27 pm

Re: Image in alert and multi platform support

Post 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.
Post Reply