Alert with icon.

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
cruzsoma
Posts: 8
Joined: Thu May 01, 2025 7:36 am

Alert with icon.

Post by cruzsoma »

Hi,
I have some problem about add sprite icon into the alert message. So come to ask some advices.

I checked this topic: https://www.pixelcrushers.com/phpbb/vie ... ite#p32925
Following your advice, I created a CustomDialogueUI inherit from StandardDialogueUI. And add a alertIcon field to it. And a new function named ShowIconAlert(string message, float duration, Sprite icon). Then I did can see a icon sprite when show alert.

I wrote a customized inventory item system. I want to register a lua function to make it selectable in script point and click mode. The function should like: ShowGotItemAlert(double itemId). Then my c# code can get target item's name and sprite icon and call the ShowIconAlert(...). This will make the entire icon alert works. (I already done some other lua function registered.)
Here is a code example I m thinking to register to Lua.

Code: Select all

public void ShowGotItemAlert(double itemId) {
Item item = xxx.GetItemById(itemId)
// localized msg with item.localizedName inside, item.localizedName is a LocalizedString
string message = xxx;
float duration = xf;
Sprite icon = item.icon

// call function inside the CustomDialogueUI
xxx.ShowIconAlert(message, duration, icon)
}
So, here is my problem:
How can I call the customized xxx.ShowIconAlert(message, duration, icon) function in my lua bridge c# code? I dont want to use find component to get the CustomDialogueUI component to do this. It ll make the architecture weird.

Also, please let me know if there is a better approach to do this.
Thanks.
cruzsoma
Posts: 8
Joined: Thu May 01, 2025 7:36 am

Re: Alert with icon.

Post by cruzsoma »

Em... Seems I got it by this code :shock: :

Code: Select all

var dialogueUI = DialogueManager.Instance.DialogueUI as CustomDialogueUI;
dialogueUI.ShowIconAlert(message, duration, icon);
And it works!
But I still want to know if there is any better approach.
Especially I want to manage the alert localization with Localization Package too.
User avatar
Tony Li
Posts: 23251
Joined: Thu Jul 18, 2013 1:27 pm

Re: Alert with icon.

Post by Tony Li »

Hi,

That's fine. That's why that property exists. You can use a shorter version like this:

Code: Select all

var dialogueUI = DialogueManager.standardDialogueUI as CustomDialogueUI;
With the Localization Package, as long as your Dialogue Manager has a DialogueSystemLocalizationPackageBridge script on it, alerts will look for localized versions of the alert text.
cruzsoma
Posts: 8
Joined: Thu May 01, 2025 7:36 am

Re: Alert with icon.

Post by cruzsoma »

Thanks for your help!
Just get the localization with dialogue system works!
User avatar
Tony Li
Posts: 23251
Joined: Thu Jul 18, 2013 1:27 pm

Re: Alert with icon.

Post by Tony Li »

Glad to help!
Post Reply