Is it possible to detect if there is a new line and change continue button for an end button?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Sociopath
Posts: 4
Joined: Thu Mar 16, 2023 7:00 pm

Is it possible to detect if there is a new line and change continue button for an end button?

Post by Sociopath »

Hi, is it possible for example have a triangle image (instead of continue button) when there are lines available and change the triangle image to a cross image when the dialogue is going to end with the next continue button action?

Basically I have changed the continue button to an image since I don't use my mouse i trigger it with my keyboard, is there any chance to swap it for another continue button when there is going to end the dialogue?
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: Is it possible to detect if there is a new line and change continue button for an end button?

Post by Tony Li »

Hi,

Yes, you can add a small script to your continue button that checks DialogueManager.currentConversationState in OnEnable. Something like:

SetContinueButtonImage.cs

Code: Select all

using UnityEngine;
using PixelCrushers.DialogueSystem;

public class SetContinueButtonImage : MonoBehaviour
{
    public Sprite continueSprite; // <-- ASSIGN THESE IN INSPECTOR.
    public Sprite endSprite;
    
    void OnEnable()
    {
        if (!DialogueManager.isConversationActive) return;
        var isEnd = !DialogueManager.currentConversationState.hasAnyResponses;
        GetComponentInChildren<Image>().sprite = isEnd ? endSprite : continueSprite;
    }
}
Sociopath
Posts: 4
Joined: Thu Mar 16, 2023 7:00 pm

Re: Is it possible to detect if there is a new line and change continue button for an end button?

Post by Sociopath »

Thanks works like a charm, great community keep the good job guys
Post Reply