VN Toggle Auto Play Button Help

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
peachthyme
Posts: 9
Joined: Wed Apr 17, 2024 11:35 pm

VN Toggle Auto Play Button Help

Post by peachthyme »

Hello,

I am using the VN framework and attempting to make it more clear that the Auto Play button toggle is on or off. I want the normalColor of the button to be a darker color when autoplay is enabled and reset to the original value (white) when it is disabled.

I thought I could achieve this by modifying the ToggleAutoPlay method in the ConversationController script by changing the normalColor of the button inside the newMode if statement check since it is called every time the button is clicked. However, the behavior is a bit strange.

Code: Select all

 
 	public Button toggleAutoPlayButton;       
        public virtual void ToggleAutoPlay()
        {
            var mode = DialogueManager.displaySettings.subtitleSettings.continueButton;
            var newMode = (mode == DisplaySettings.SubtitleSettings.ContinueButtonMode.Optional) ? DisplaySettings.SubtitleSettings.ContinueButtonMode.Always : DisplaySettings.SubtitleSettings.ContinueButtonMode.Optional;
            DialogueManager.displaySettings.subtitleSettings.continueButton = newMode;
            ColorBlock cb = toggleAutoPlayButton.colors;
            if (newMode == DisplaySettings.SubtitleSettings.ContinueButtonMode.Optional){
                cb.normalColor = new Color(0.5f, 0.5f, 0.5f, 1);
                dialogueUI.OnContinueConversation();
            } 
            else
            {
                cb.normalColor = Color.white;
            }
            toggleAutoPlayButton.colors = cb;
        }
        
(I changed the code from "never" to "optional" because I would like the player to be able to click though things faster if they really wanted to, even if autoplay is enabled)

When clicking the button and enabling autoplay, I see that the "continue button" section for the Dialogue System Controller Subtitle Settings becomes "optional" as expected on click However, the color of the button doesn't change or update until I click continue on the screen or a menu option at least once. The button then correctly stays the new color and autoplay functions as normal. If I click the button to disable autoplay, the normalColor correctly resets back to white on click.

I am not sure why the button is not updating to the new color at the same time that the Dialogue System Controller Subtitle Setting is changed.

Another question I had was that if I disable autoplay in the middle of the dialogue typewriter animation still completing, it still autoplays that conversation node and loads up the next one. I am not sure if it is related to me changing the Default Sequence setting of the Camera and Cutscenes settings being set to Delay(1)@{{end}} (followed https://www.pixelcrushers.com/phpbb/viewtopic.php?t=925 as I wanted this timed behavior for the autoplay functionality) but I would like the autoplay on or off to be immediate.

Any help is appreciated!
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: VN Toggle Auto Play Button Help

Post by Tony Li »

Hi,
peachthyme wrote: Tue Jun 18, 2024 10:55 pmI thought I could achieve this by modifying the ToggleAutoPlay method in the ConversationController script by changing the normalColor of the button inside the newMode if statement check since it is called every time the button is clicked. However, the behavior is a bit strange.
Instead of directly modifying ConversationControl.cs, I recommend making a subclass. This way you won't lose your customizations when you update the Dialogue System.

Also, what if you change the button's Image component or Text/TextMeshProUGUI component's Color value instead?

Example:

Code: Select all

public class MyConversationControl : ConversationControl
{
    public Button toggleAutoPlayButton; 
    
    public override void ToggleAutoPlay()
    {
        var mode = DialogueManager.displaySettings.subtitleSettings.continueButton;
        var isAutoPlaying = (mode == DisplaySettings.SubtitleSettings.ContinueButtonMode.Optional);
        var newMode = isAutoPlaying
            ? DisplaySettings.SubtitleSettings.ContinueButtonMode.Always 
            : DisplaySettings.SubtitleSettings.ContinueButtonMode.Optional;
        DialogueManager.displaySettings.subtitleSettings.continueButton = newMode;
        isAutoPlaying = !isAutoPlaying;
        if (isAutoPlaying) dialogueUI.OnContinueConversation();
        toggleAutoPlayButton.GetComponent<Image>().color = isAutoPlaying
            ? new Color(0.5f, 0.5f, 0.5f, 1);
            : Color.white;
    }
}
peachthyme wrote: Tue Jun 18, 2024 10:55 pmAnother question I had was that if I disable autoplay in the middle of the dialogue typewriter animation still completing, it still autoplays that conversation node and loads up the next one. I am not sure if it is related to me changing the Default Sequence setting of the Camera and Cutscenes settings being set to Delay(1)@{{end}} (followed https://www.pixelcrushers.com/phpbb/viewtopic.php?t=925 as I wanted this timed behavior for the autoplay functionality) but I would like the autoplay on or off to be immediate.
Your dialogueUI.OnContinueConversation() code should work. Are there any errors or warnings in the Console window?
Post Reply