Page 1 of 1

Alert with icon.

Posted: Thu May 01, 2025 7:56 am
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.

Re: Alert with icon.

Posted: Thu May 01, 2025 10:50 am
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.

Re: Alert with icon.

Posted: Thu May 01, 2025 6:35 pm
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.

Re: Alert with icon.

Posted: Sat May 03, 2025 11:12 am
by cruzsoma
Thanks for your help!
Just get the localization with dialogue system works!

Re: Alert with icon.

Posted: Sat May 03, 2025 11:35 am
by Tony Li
Glad to help!