Bool for PC Response Menu next or not (Continue Button)

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
ar4wy
Posts: 26
Joined: Fri Nov 15, 2019 10:16 pm

Bool for PC Response Menu next or not (Continue Button)

Post by ar4wy »

Hi Pixel Crushers!

I'm having an issue locating an event where I can access if the dialogue being spoken has PC response menu next or not.

I'm trying to only show the continue button on certain events.

1. When Subtitle typewriter is active = do not show continue button, but allow continueFastFoward for typewriter

2. When Typewriter is done = show continue button, to prompt input

3. IF Typewriter is done, but a PC response menu is next = DO NOT SHOW continue button (because response menu is next).

A little help would be greatly appreciated :) I tried to get access to the ConversationState.hasPCResponses bool, but I couldn't get it in script--I probably don't know how to access this properly.

However is the best way to approach this, please let me know!

All the best!
User avatar
Tony Li
Posts: 22054
Joined: Thu Jul 18, 2013 1:27 pm

Re: Bool for PC Response Menu next or not (Continue Button)

Post by Tony Li »

Hi,

Here's how to get ConversationState.hasPCResponses:

Code: Select all

bool hasPCResponses = DialogueManager.currentConversationState.hasPCResponses;
ar4wy
Posts: 26
Joined: Fri Nov 15, 2019 10:16 pm

Re: Bool for PC Response Menu next or not (Continue Button)

Post by ar4wy »

Hi Tony,

Thanks so much! Everything is working now, but I get this in the console, referring to the line I get the bool.

"NullReferenceException: Object reference not set to an instance of an object"

Here is my script:

It is attached the highest gameobject in the Dialogue Manager right now. (it was originally attached to the text of the continue button, but i had the same error.)

The Text component is the text component on the continue button.

Code: Select all

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

public class ContinueButtonHide : MonoBehaviour
{

    public Text text;

    // Start is called before the first frame update
    void Awake()
    {
    }

    private void OnEnable()
    {
        bool hasPCResponses = PixelCrushers.DialogueSystem.DialogueManager.currentConversationState.hasPCResponses;

        if(hasPCResponses)
        {
            text.text = "";
        } 
        else
        {
            text.text = ">>";
        }

    }

    private void OnDisable()
    {
        text.text = "";
    }

}
Thanks for your help!
User avatar
Tony Li
Posts: 22054
Joined: Thu Jul 18, 2013 1:27 pm

Re: Bool for PC Response Menu next or not (Continue Button)

Post by Tony Li »

Hi,

You can either change the OnEnable() method to OnConversationLine(Subtitle subtitle) so it will only be called when showing a subtitle, or you can check if a conversation is active:

Code: Select all

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

public class ContinueButtonHide : MonoBehaviour
{
    public Text text;

    private void OnEnable()
    {
        if (!DialogueManager.isConversationActive) return; // <-- ADD THIS
        bool hasPCResponses = PixelCrushers.DialogueSystem.DialogueManager.currentConversationState.hasPCResponses;
        if(hasPCResponses)
        {
            text.text = "";
        } 
        else
        {
            text.text = ">>";
        }

    }

    private void OnDisable()
    {
        text.text = "";
    }

}
ar4wy
Posts: 26
Joined: Fri Nov 15, 2019 10:16 pm

Re: Bool for PC Response Menu next or not (Continue Button)

Post by ar4wy »

Thanks, Tony!
Post Reply