Hi, I stopped studying Dialogue System for Unity for a while, but I'm back again. I really enjoy learning about this tool because the more I look into it, the more things I can do with it. Thank you for developing this great tool.
Let's get down to the subject. I understand how to display a timer for the response menu, but I would like to display a timer for text input as well. Is this possible? If so, please tell me the way.
Thank you in advance!
Re: How to show a timer when text field UI is shown?
Posted: Fri Sep 02, 2022 7:57 am
by Tony Li
Hi,
There isn't anything built-in to display a timer for text input. You could make a custom sequencer command to do that, or subclass SequencerCommandTextInput to add that functionality.
Re: How to show a timer when text field UI is shown?
Posted: Sat Sep 03, 2022 9:31 pm
by misaki_e
Sorry for the delay in response, thank you for your quick reply!
I see, I haven't gotten to the point of actually implementing it yet, but your answer was helpful to find a path. I will try that!
Re: How to show a timer when text field UI is shown?
Posted: Sun Sep 04, 2022 4:53 am
by misaki_e
Thanks to your answer I was able to create a custom sequencer command, but the Timer countdown does not start.... I wrote the following code:
In it, I copied the SequencerCommandTextInput.cs script and just added some code to run a timer slider.
Re: How to show a timer when text field UI is shown?
Posted: Sun Sep 04, 2022 10:56 pm
by misaki_e
Thank you for going to the trouble of providing a complete script! After confirming the script you provided, I finally understood that all I had to do was to create a custom sequence command by adding some code to show a Timer(slider) to the `TextInput` sequence command. Now I was able to accomplish what I wanted to do, but I think there are still parts I don't 100% understand how to create custom sequence commands, so I would like to check the scripts you provided carefully to deepen my understanding. Thank you for your time!
Re: How to show a timer when text field UI is shown?
Posted: Mon Sep 05, 2022 8:16 am
by Tony Li
Glad to help! If you have questions about writing your own sequencer commands, let me know.
Re: How to show a timer when text field UI is shown?
Posted: Tue Sep 06, 2022 3:23 am
by misaki_e
I thought I got the timer to display well with the script you provided me, but now I am running into two issues
The first major problem is that it works when an “InGame" scene is loaded from a “Title" scene, but not when an "InGame" scene is played directly. First of all, when played from the “Title" scene, the movement looks like the video below (I am currently making a kind of quiz game. Sorry for the UI text in Japanese.):
The blow is the video recording when I start from "InGame" scene:
The first Text Input works fine in both cases, but the second time I get a console message that Timer(slider) is null.
NullReferenceException: Object reference not set to an instance of an object
PixelCrushers.DialogueSystem.SequencerCommands.SequencerCommandTimedTextInput.Update () (at Assets/Dialogue System Examples/Timed TextInput Example/SequencerCommandTimedTextInput.cs:76)
I've added some Debug.Log lines to the custom sequence script, so the line numbers are off from the original script you provided. Here it is on line 76 of my script:
I have tried various ideas as to why I cannot get a Timer, but I cannot figure out the cause. Then, I tried with the example scene you provided to see if it would work when I requested text input twice, but it did not. Do you have any ideas for a solution?
----
The second problem is that the timer cannot be hidden at the start of the InGame scene. This is the same when loaded from the Title scene. Do you know the reason why it can't be hidden at first like the other UI GameObjects?
I’m sorry to bother you again, but I would appreciate it if you could advise me to solve these issues.
Re: How to show a timer when text field UI is shown?
Posted: Tue Sep 06, 2022 11:20 am
by Tony Li
Hi,
If it works when coming from the Title scene but not when playing the InGame scene, then your Dialogue Manager may be configured differently in each scene. I recommend these steps:
1. Open the Title scene.
2. Drag the Dialogue Manager GameObject into your Project view to create a new Prefab Variant.
3. Save the Title scene.
4. Open the InGame scene.
5. Remove the Dialogue Manager GameObject from the InGame scene.
6. Add the new Prefab Variant to the InGame scene.
7. Save the InGame scene and test it.
For the issue where the slider is visible at start, which slider is visible? The one inside the Text Field UI or the response menu panel's regular timer slider? If it's the one inside the Text Field UI, move it to be a child of the Text Field Panel:
timerInsideTextFieldPanel.png (18.89 KiB) Viewed 1011 times
Re: How to show a timer when text field UI is shown?
Posted: Tue Sep 06, 2022 7:21 pm
by misaki_e
Thank you for your quick reply, but unfortunately, both don't seem to solve the problems.
First, my Title scene doesn't have a Dialogue Manager GameObject.
Screen Shot 2022-09-07 at 8.07.51.png (12.83 KiB) Viewed 1004 times
Therefore, I am unable to follow the steps you have given me.
For the issue where the slider is visible at start, the slider shown is for Text Input. The current hierarchy is here:
Screen Shot 2022-09-07 at 8.11.28.png (24.02 KiB) Viewed 1004 times
I tried making it a child of the Text Field Panel as you suggested, but it stopped the scene at the first text input. The error log is here:
NullReferenceException: Object reference not set to an instance of an object
PixelCrushers.DialogueSystem.SequencerCommands.SequencerCommandTimedTextInput.Start () (at Assets/Dialogue System Examples/Timed TextInput Example/SequencerCommandTimedTextInput.cs:69)