Page 1 of 1
Action on continue button
Posted: Wed May 14, 2025 7:02 am
by jrose1184
Hi,
How do i detect when the continue button is pressed on the dialogue i want to call an animation state every time that button is pressed please.
Also when my game is in game over state i want to destroy all runnng dialouges is there a function that also?
thanks
Re: Action on continue button
Posted: Wed May 14, 2025 7:57 am
by Tony Li
Hi,
> How do i detect when the continue button is pressed on the dialogue i want to call an animation state every time that button is pressed please.
You can hook up your method to the continue button's OnClick() event -- or, if you're using StandardUIContinueButtonFastForward, you can make a subclass that overrides OnFastForward to also call your animation state. Alternatively, you can add a script to the Dialogue Manager that has an
OnConversationLineEnd() method.
> Also when my game is in game over state i want to destroy all runnng dialouges is there a function that also?
Yes. Use DialogueManager.StopAllConversations();
Re: Action on continue button
Posted: Sat May 17, 2025 10:54 am
by jrose1184
Hi thanks. So i did what you said and added a sub class like so
Code: Select all
using UnityEngine;
using PixelCrushers.DialogueSystem;
public class CustomContinueButton : StandardUIContinueButtonFastForward
{
private static Animator staticAnimator;
private static string staticTriggerName = "talking";
private static string staticSpeakerName = "LemonDemo";
public static void Configure(Animator animator, string triggerName, string speakerName)
{
staticAnimator = animator;
staticTriggerName = triggerName;
staticSpeakerName = speakerName;
}
public override void OnFastForward()
{
base.OnFastForward();
string currentSpeaker = DialogueManager.instance.CurrentActor != null
? DialogueManager.instance.CurrentActor.name
: string.Empty;
Debug.Log("CustomContinueButton: OnFastForward called by speaker: " + currentSpeaker);
if (!string.IsNullOrEmpty(currentSpeaker) && currentSpeaker == staticSpeakerName)
{
if (staticAnimator != null)
{
Debug.Log("Triggering animation: " + staticTriggerName);
staticAnimator.SetTrigger(staticTriggerName);
}
}
}
}
and then when i start a converstion i call it like so
Code: Select all
if (GameManager.instance.playerAttackedFirst && !battleManager.playerAttacked)
{
battleManager.playerAttacked = true;
DialogueLua.SetVariable("PlayerAttackedFirst", true);
Animator playerAnimator = battleManager.lemon.GetComponent<Animator>();
if (playerAnimator != null)
{
playerAnimator.SetTrigger("talking");
}
CustomContinueButton.Configure(
playerAnimator,
"talking",
"LemonDemo"
);
DialogueManager.StartConversation("Battle Demo", battleManager.player, battleManager.lemon);
}
but for some reason it returning the wrong actor. i have checked the tree and the actor is lemon and no cola. am i doing somthing rong here.
Re: Action on continue button
Posted: Sat May 17, 2025 3:42 pm
by Tony Li
Hi,
DialogueManager.currentActor will always be the conversation's actor (i.e., battleManager.player). If you want to get the transform of the current dialogue entry's speaker, use DialogueManager.currentConversationState.subtitle.speakerInfo.transform.