Page 1 of 2
How to Stack Alert messages
Posted: Wed Oct 06, 2021 9:29 am
by 2gold
Hello, I'm still making the game well using the Dialog System Asset.
I'm curious if I can get an idea while using the asset.
I wonder if I can implement the functions I want to create currently using the conversation system.
The function I want to create is a function that stacks Alert Messages in the same format as Log and uses them like an indicator.
During the game or conversation, I was planning to use ShowAlert at the desired time.
(And this message doesn't disappear until a certain number of times)
Like this :
- Sample_indicator_2.png (22.6 KiB) Viewed 961 times
However, if you duplicate and use the Alert Message component several times, several Alert Messages will only be output in order as follows :
- sample_indicator.gif (43.33 KiB) Viewed 961 times
Can I use the Dialogue System to create the functions I want?
Should we use the Alert Message or create a UI type exclusively for indicators?
If you have any ideas, please let me know. Thank you!
* I used a translator.
Re: How to Stack Alert messages
Posted: Wed Oct 06, 2021 9:48 am
by Tony Li
Hello,
The dialogue UI code does not stack messages, but you can make a subclass of
StandardDialogueUI to use your own code to show stacked messages. Override the ShowAlert() method to show the alert in your own UI that it written to stack messages. Example:
Code: Select all
public class MyDialogueUI : StandardDialogueUI
{
public override void ShowAlert(string message, float duration)
{
// ** Your code here. Example: **
StackedMessageUI.ShowAlert(message, duration);
}
}
Re: How to Stack Alert messages
Posted: Thu Oct 07, 2021 8:20 am
by 2gold
Hello, thank you for the idea.
However, I'm asking you additional questions because it doesn't seem to work as intended.
1. I thought of the structure of receiving the message value received as a ShowAlert function through override and handing it over to the custom UI, and I wrote it the same as the code you wrote down. And I took a
Debug.Log to see if the message value came in.
Code: Select all
public class CHUDManager : StandardDialogueUI
{
public override void ShowAlert(string message, float duration)
{
Debug.Log(message);
}
}
2. I put a test Dialogue System Trigger in the scene and created the following sequence through Play Sequence.
- Sample_1.png (30.58 KiB) Viewed 936 times
3. The script was attached to the HUD Canvas as follows.
- sample_2.png (16.2 KiB) Viewed 936 times
- sample_3.png (20.03 KiB) Viewed 936 times
4. However, when you run it, you can see that you are outputting a Show Alert from the Dialogue System message, but the message you have received is not captured as Debug.Log.
- sample_4.png (141.19 KiB) Viewed 936 times
It is difficult to track the problem due to low coding proficiency:(
Will I be missing something?
Re: How to Stack Alert messages
Posted: Thu Oct 07, 2021 9:07 am
by Tony Li
Hi,
ShowAlert() is not a sequencer command. It's a Lua function. In conversations, put it in the
Script field.
If you're using a Dialogue System Trigger, use a
Show Alert action. Alternatively, you can use a Run Lua Code action, but it's not really necessary since there's a dedicated Show Alert action:
- showAlert.png (30.91 KiB) Viewed 935 times
Re: How to Stack Alert messages
Posted: Thu Oct 07, 2021 12:07 pm
by 2gold
Oh, I didn't know that! Thank you.
We confirmed that ShowAlert was connected normally from the existing StandardUI using the Lua Code.
However, the value of Debug.Log remains unchanged. For some reason, the Override script content attached to the Custom UI does not seem to be running.
The only response to the ShowAlert() call is the Alert Panel of the StandardUI referenced by the Dialogue System.
- Sample_ui.png (20.27 KiB) Viewed 933 times
(To explain the environment in case it helps, there are
MainScene and
RoomScene, and Dialogue Manager is located in MainScene. The Custom Alert UI is located in RoomScene. It is played in the order of
MainScene->RoomScene.)
Re: How to Stack Alert messages
Posted: Thu Oct 07, 2021 3:46 pm
by Tony Li
Alerts will use the current dialogue UI. In other words, they'll be shown using DialogueManager.dialogueUI.ShowAlert().
By default, the Dialogue Manager in MainScene will survive into RoomScene, supplanting any Dialogue Manager that might be in RoomScene.
This means alerts will go through the MainScene Dialogue Manager's Dialogue UI.
However, there are ways to tell the Dialogue Manager to use a different dialogue UI, such as the Override Dialogue UI component or using the C# method DialogueManager.UseDialogueUI(). If you haven't done any of that, however, alerts will use the dialogue UI that was assigned to the Dialogue Manager in MainScene.
Re: How to Stack Alert messages
Posted: Fri Oct 08, 2021 2:21 am
by 2gold
Thank you for your continued help. I finally succeeded in uploading the Debug.log!
- sample_yay.png (8.53 KiB) Viewed 922 times
Re: How to Stack Alert messages
Posted: Fri Oct 08, 2021 5:05 am
by 2gold
I thought it was solved, but there was a problem at the end of the last.
I connected the Override ShowAlert to the game manager and succeeded in creating an indicator every time I called ShowAlert(). (hooray!)
- Sample_.gif (58.78 KiB) Viewed 918 times
However, if you try to screen the string value taken from ShowAlert into UIText, the following problems arise.
May I know what caused this error?
- Sample_error.png (52.87 KiB) Viewed 918 times
.
.
Each script is as follows:
DialogueUI
Code: Select all
public class CustomDialogueUI : StandardDialogueUI
{
public override void ShowAlert(string message, float duration)
{
CGameManager.instance.IndicatorAlert(message);
}
}
GameManager
Code: Select all
public void IndicatorAlert(string AlertTxt) //Call for creating an indicator.
{
HUDmanager = GameObject.Find("HUDCanvas").GetComponent<HUDManager>();
HUDmanager.IndicatorSetting(AlertTxt);
}
HUD Manager (Receive alert data and create indicator items.)
Code: Select all
public class HUDManager : MonoBehaviour
{
public GameObject Prefabs;
public Transform TargetPath;
public void IndicatorSetting(string data) //Create and place indicator items.
{
GameObject items = Instantiate<GameObject>(Prefabs, TargetPath);
CItemIndicator itemdata = GetComponent<CItemIndicator>();
itemdata.AlertData(data);
}
}
itemdata.AlertData(data) has a function of putting the received string value into UIText.text.
Thank you!
Re: How to Stack Alert messages
Posted: Fri Oct 08, 2021 8:14 am
by Tony Li
Hi,
The first error (NullReferenceException in line 16 HUDManager) doesn't make sense with the version of HUDManager.cs you posted because it doesn't have 16 lines. So I'll assume you fixed that error and shortened HUDManager.cs before posting here.
The second error means the built-in ShowAlert() Lua function has been unregistered, or wasn't registered in the first place. Does the scene have a Dialogue Manager GameObject?
Re: How to Stack Alert messages
Posted: Fri Oct 08, 2021 11:04 am
by 2gold
HUD Manager's line 16 is as follows.
- sample_16.png (12.16 KiB) Viewed 914 times
There is no problem when you write DebugLog on Line 16. An error occurs when trying to insert the string received through ShowAlert into UItext.text, whether from HUDManager or CItem Indicator.
This is the appearance of Hierarchy
The scene moves in the order of MainMenu -> Loading -> Chamber, and the Dialogue Manager located in MainMenu has DontDestroy.
- sample_MainMenuHier.png (13.32 KiB) Viewed 914 times
(Chamber is repeatedly loaded, and HUDCanvas is placed in Chamber scene to initialize the accumulated indicators each time it is loaded.)
- Sample_Chamber.png (25.76 KiB) Viewed 912 times
Indicator Manager is a node with a DIalogue System Trigger component for ShowAlert() testing.
I hope it helps.