SetDialoguePanel & SetActive not working.

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
sylargaf
Posts: 3
Joined: Wed Feb 16, 2022 9:00 pm

SetDialoguePanel & SetActive not working.

Post by sylargaf »

Hey all.

Just bought this today and have been experimenting around. One thing I am trying to do is delay the start of a conversation to a specific time (9s) and that includes hiding the entire UI in that 9s. Doing some research on these forums I tried to find a way to solve this, coming across this:

https://www.pixelcrushers.com/phpbb/vie ... art#p28978

Code: Select all

SetDialoguePanel(false, immediate);
Delay(2);
SetDialoguePanel(true)@2
Which I tried, but I couldn't get to work. Well, it'll delay, but the SetDialoguePanel doesn't work. After some more research I found to try this:

Code: Select all

SetActive(Dialogue Panel, false); Delay(9); SetActive(DialoguePanel);
Try that, and the first two calls in the sequence work, but it wouldn't SetActive to true after.

So i'm at a loss. I'm sure i'm missing something obvious but hoping for some help.

Similirarly, is there a tutoril anywheres that shows how to use this system such as starting conversation withing C#?

Thank you!
sylargaf
Posts: 3
Joined: Wed Feb 16, 2022 9:00 pm

Re: SetDialoguePanel & SetActive not working.

Post by sylargaf »

I did some more testing and found the following.

When I try:

Code: Select all

SetDialoguePanel(false, immediate);
Delay(2);
SetDialoguePanel(true)@2 
it does seem to work, however, the text & compnent aren't showing up on the screen. But, in the Heirarchy you can see that the text field is being populated. Any wy to fix this?
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: SetDialoguePanel & SetActive not working.

Post by Tony Li »

Hi,

To start a conversation from C# code, use DialogueManager.StartConversation().
(More info: Commonly Used API Calls)

To delay the start, SetDialoguePanel() should work. If you're not using continue buttons, this will do:

Code: Select all

SetDialoguePanel(false, immediate);
SetDialoguePanel(true)@9
No need for the Delay(9) since the sequence will wait until the 9-second mark anyway for SetDialoguePanel(true).

If you're using continue buttons, change it to this:

Code: Select all

SetDialoguePanel(false, immediate);
required SetDialoguePanel(true)@9;
Continue()@9
The Continue()@9 simulates a continue button click at the 9-second mark. The 'required' keyword in front of SetDialoguePanel(true) guarantees that the command runs even if the Continue() happens to run first at the 9-second mark.

Here's an example scene:

DS_DelayedStartExample_2022-02-16.unitypackage

(The example waits 3 seconds.)

If the same thing doesn't work in your scene, it's possible that there's an issue with the main panel's Animator configuration.

Another way to hide and show the dialogue UI without impacting the Animator is to:

1. Give the Dialogue Manager's Canvas (or whatever canvas you're using for the dialogue UI) a unique name such as "DialogueCanvas".

2. Use the SetEnabled() sequencer command to disable and enable the canvas:

Code: Select all

SetEnabled(Canvas, false, DialogueCanvas);
required SetEnabled(Canvas, true, DialogueCanvas))@9;
Continue()@9

If you're starting the conversation when the scene starts, another way to delay the conversation is to use a Timed Event component instead of making the first node hide and delay with SetDialoguePanel:
timedEventDelayedStart.png
timedEventDelayedStart.png (41.86 KiB) Viewed 386 times
sylargaf
Posts: 3
Joined: Wed Feb 16, 2022 9:00 pm

Re: SetDialoguePanel & SetActive not working.

Post by sylargaf »

That worked perfectly, thank you so much! :)
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: SetDialoguePanel & SetActive not working.

Post by Tony Li »

Happy to help!
Post Reply