Page 1 of 1

Set up UI for a given node, preferably in edit mode?

Posted: Wed Oct 11, 2023 10:38 am
by Aki Kanerva
Hi there!

I'm working on automation for taking screenshots of every single conversation node. My aim is to write an automation script that goes through all nodes in a conversation and renders the relevant UI as it would appear in-game.

I have two related questions:

1. How do I tell Dialogue System to jump to a specific node without progressing through the entire tree? There are some cases where nodes have dependencies to a previous node, eg. a previously-set background, but they aren't game-spanning and it should be possible to collapse them.

2. How would I go about rendering StandardDialogueUI (ie. building the canvas) in Edit Mode? This would significantly speed up automation compared to running in Play Mode.

Edit: I'm happy to edit the source code if necessary, though if this can be avoided, it'll make maintenance easier.

Thanks!

Re: Set up UI for a given node, preferably in edit mode?

Posted: Wed Oct 11, 2023 11:59 am
by Tony Li
Hi,

You can't render StandardDialogueUI in edit mode. It depends on runtime values. However, you can write a runtime (not editor) script to run through all lines of dialogue in a conversation and take screenshots. Note that if you're using [var=variable] or [lua(code)] markup tags in your dialogue text, they may not show proper values if you aren't playing through the conversation the intended way.

To run through all entries in all conversations, do something like:

Code: Select all

using System.Collections;
using UnityEngine;
using PixelCrushers.DialogueSystem;

public class ScreenshotConversations : MonoBehaviour
{
    IEnumerator Start()
    {
        foreach (var conversation in DialogueManager.masterDatabase.conversations)
        {
            DialogueManager.StartConversation(conversation.Title);
            foreach (var entry in conversation.dialogueEntries)
            {
                if (entry.id == 0 || entry.isGroup) continue; // Skip <START> and group entries.
                var state = DialogueManager.conversationModel.GetState(entry);
                state.subtitle.sequence = "WaitForMessage(Forever)"; // Don't play entry's regular sequence.
                DialogueManager.conversationController.GotoState(state);
                yield return null;
                DialogueManager.standardDialogueUI.conversationUIElements.defaultNPCSubtitlePanel.GetTypewriter().Stop();
                // Take your screenshot here
                yield return new WaitForSeconds(0.2f); // Wait a bit so you can see what's going on.
            }
            DialogueManager.StopConversation();
        }
    }
}

Re: Set up UI for a given node, preferably in edit mode?

Posted: Thu Oct 12, 2023 4:50 am
by Aki Kanerva
Thank you, Tony! This looks like a great starting point.

There are some {(if:variable=true)text} segments in the dialogue text, so we'll need to figure out 1) how to detect variables in a given node and 2) how to pass each value to the conversation controller. But that sounds like it should be doable.

Re: Set up UI for a given node, preferably in edit mode?

Posted: Thu Oct 12, 2023 8:05 am
by Tony Li
Hi,

If you use [lua(Conditional(variable, text))] in your text, the code above will automatically take care of it. If variable is true, it will include text. Otherwise it won't.