Page 1 of 1
Is it possible to detect if there is a new line and change continue button for an end button?
Posted: Sat Apr 29, 2023 4:08 pm
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?
Re: Is it possible to detect if there is a new line and change continue button for an end button?
Posted: Sat Apr 29, 2023 6:07 pm
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;
}
}
Re: Is it possible to detect if there is a new line and change continue button for an end button?
Posted: Sat Apr 29, 2023 7:01 pm
by Sociopath
Thanks works like a charm, great community keep the good job guys
Re: Is it possible to detect if there is a new line and change continue button for an end button?
Posted: Sat Apr 29, 2023 8:50 pm
by Tony Li
Glad to help!