Page 1 of 1

Issue activating/deactivating the Dialogue UI

Posted: Thu May 23, 2019 5:00 pm
by allisonrose
Hi there!
I've got an odd situation that I hope you can help me sort out. I've been fiddling with it for days but had no luck.


Here's what I'm trying to do:

A conversation plays as normal. After this conversation ends, The game takes the player to a Navigational map, which operates in 2d Worldspace. The player scrolls the camera left/right across the map and they can click on different buttons to take them to different locations (the "locations" are just different backgrounds being activated). In these locations, new conversations will start.

Here's what I have tried to make this work:

I set up a test in a fresh project just to remove any extra variables from all the stuff in my main project that might be messing with this. It didn't work in my main project either, so I assume I'm just missing some step I need to do.

In the new project I have just Dialogue System and the VN Framework. I'm testing this using the VN framework's demo scenes.

After the demo "Start Conversation" plays, I have sequencer commands on the last node set to activate my Worldspace UI which contains the buttons the player will use to navigate, Activate the Map image, as well as enable a component on the main camera that lets the player use the left/right arrow keys to slide the camera back and forth.

In order to make my Worldspace UI clickable, I've had to deactivate the regular Dialogue UI Canvas as well. I tried making this work with both UI canvases active, but had no luck.

In my Worldspace UI, I have a button that starts a new conversation on click. I am using this Switch Conversation script on the button to end the current conversation (demo Start Conversation) and start up a new one.

Code: Select all

using UnityEngine;
using PixelCrushers.DialogueSystem;
using UnityEngine.UI;

public class ChangeConversationButton : MonoBehaviour
{
    [ConversationPopup]
    public string newConversation;
    public Transform actor;
    public Transform conversant;

    public void Start()
    {
        GetComponent<UnityEngine.UI.Button>().onClick.AddListener(ChangeConversation);
    }

    public void ChangeConversation()
    {
        DialogueManager.StopConversation();
        DialogueManager.StartConversation(newConversation, actor, conversant);
    }
}




The script appears to work, as I notice in the Dialogue window that the node has changed to the Start node of the new conversation.
I am also reactivating the Dialogue UI's canvas and deactivating the Worldspace Canvas at the start of the new conversation.

Watching the hierarchy while in play mode shows that everything is being activated/deactivated as intended.

However, nothing is showing on screen. The Dialogue UI canvas is activated, but I am not seeing the subtitle panels appearing, so I can't interact with the current conversation.


I'm a bit lost on what I should do to fix this, or if i am even handling the situation in the correct manner.

Thanks for your time!

Re: Issue activating/deactivating the Dialogue UI

Posted: Thu May 23, 2019 7:12 pm
by Tony Li
Hi,

What if you let the "Start Conversation" conversation finish normally? Your 2D world space UI should be up, since it's activated by sequencer commands in the conversation's last dialogue entry node, so the player won't be left hanging with nothing onscreen.

If you let the conversation finish normally, you may not need to hide the dialogue UI's canvas.

If you end up needing to hide it, though, disable the Canvas component; don't deactivate its GameObject. If you deactivate the GameObject, it will reset the animators, which could put them into an unexpected state. The combination of the active conversation and the deactivated GameObject is probably what's causing the issue. The dialogue UI thinks it's already visible so it doesn't play the "Show" animation (fade in). But since the Canvas GameObject was deactivated and reactivated, the dialogue UI's animator will have reset to the hidden state.

In fact, now that I think about it, if you're currently deactivating the GameObject, then the only change you may need to make is to disable the Canvas instead. Everything else might start working correctly the way you have it now.

Re: Issue activating/deactivating the Dialogue UI

Posted: Thu May 23, 2019 9:46 pm
by allisonrose
Hey Tony!

Disabling the Canvas component did the trick!

Actually, just letting the conversation stop also worked, but it had an issue where the map would activate, but I'd have to click one more time to get the buttons to be usable (I guess because the activation is happening on the last node, and I have to click the "continue button" to get the conversation to end) Is there by any chance a way to have it Auto Continue just for one node?

Re: Issue activating/deactivating the Dialogue UI

Posted: Thu May 23, 2019 10:05 pm
by Tony Li
Sure. Set the last node's Sequence to:

Code: Select all

Continue()@{{end}}
This will simulate a continue button click after a duration determined by the length of the text.

If you have a visible continue button and want to hide it, use this Sequence:

Code: Select all

SetContinueMode(false);
Continue()@{{end}}

Re: Issue activating/deactivating the Dialogue UI

Posted: Thu May 23, 2019 10:20 pm
by allisonrose
Thanks again, Tony!

Re: Issue activating/deactivating the Dialogue UI

Posted: Fri May 24, 2019 10:14 am
by Tony Li
Happy to help!

Re: Issue activating/deactivating the Dialogue UI

Posted: Sun May 26, 2019 3:09 pm
by allisonrose
Hi again!

Just thought i'd piggy back on my previous post so as not to clutter the forum with new posts.

I'm currenty having an issue with saving and loading. Everything works as intended the first time around, but is behaving strangely when I load from a save.

here's what is happening

1. User enters Map Navigation screen.
2. User saves game on map screen.
4. User loads that saved game, returns to Map screen as intended.
3. User clicks a button on the map which is scripted to start a new conversation. (using the script I pasted above)
3. Instead of showing the new conversation, game goes to Main menu. (the debug log here says "Reached the end. Returning to main menu." but the dialogue window shows that the game has in fact moved to the new conversation and is on the correct node, which is NOT the end.)
4. If at this point, I click "Restart" the previous conversation is on screen. That is, the conversation that the user was supposed to see before the game went to the main menu.

Is this an issue with the save system, or is something else entirely happening?

Re: Issue activating/deactivating the Dialogue UI

Posted: Sun May 26, 2019 3:43 pm
by Tony Li
Hi,

This has to do with the way the visual novel framework works, not specifically with the Dialogue System itself.

In the Start scene, inspect the Visual Novel Menu Canvas. Untick the Menus component's Return To Menu On Conversation End checkbox.

I think that should fix it. If not, we can dig a little deeper.

Re: Issue activating/deactivating the Dialogue UI

Posted: Sun May 26, 2019 4:01 pm
by allisonrose
agh I SWEAR I had that unchecked but I guess I'm just a doofus. lol

Thanks again!

Re: Issue activating/deactivating the Dialogue UI

Posted: Sun May 26, 2019 4:07 pm
by Tony Li
You're welcome! If that doesn't do the trick, just let me know.