SetContinueMode Forcing Conversation to Auto Progress

Announcements, support questions, and discussion for the Dialogue System.
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: SetContinueMode Forcing Conversation to Auto Progress

Post by Tony Li »

Hi,
jae026 wrote: Tue Nov 17, 2020 10:51 amHey, I tried the script change and the third one still appears.
That script change works in the repro project that you sent me. Can you share the current content of your CurrentResponsePage script?
jae026 wrote: Tue Nov 17, 2020 10:51 amAlso, where can In set the volume of audioclips played from nodes? They seem to be set to max volume.
Audio clips play on an Audio Source component. Sequencer commands such as AudioWait() operate on a GameObject that it refers to as the subject.; For example, in this command:

Code: Select all

AudioWait(hello, Bob)
the subject is the GameObject named 'Bob'. If Bob has an Audio Source component, AudioWait() will use it. If it doesn't already have an Audio Source component, AudioWait() will create a default one with max volume. If you want to adjust the subject's volume, 2D/3D panning, mixer channel, etc., add an Audio Source and configure it.

If you omit the subject from the AudioWait() command:

Code: Select all

AudioWait(hello)
then it will use the GameObject that's assigned as the node's speaker.

If you need to confirm which GameObject is assigned as the node's speaker, temporarily set the Dialogue Manager's Other Settings > Debug Level to Info. This will log info to the Console. When a conversation starts, look for a line such as:

Dialogue System: Starting conversation 'title' with actor=AAA and conversant=BBB

where AAA and BBB are the GameObjects of the conversation's primary participants.
jae026
Posts: 51
Joined: Wed Apr 15, 2020 10:22 pm

Re: SetContinueMode Forcing Conversation to Auto Progress

Post by jae026 »

Code: Select all

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

public class CurrentResponsePage : MonoBehaviour
{
    public int currentPage = 0;

    [Space]
    public List<Button> Pages = new List<Button>();

    public void Enable()
    {
        currentPage = 0;
    }




    public void UpdateCurrentPageUp()
    {
        var isNextResponseValid = currentPage <= DialogueManager.currentConversationState.pcResponses.Length && DialogueManager.currentConversationState.pcResponses[currentPage].enabled;

        if (currentPage <= Pages.Count - 1 && isNextResponseValid)
        {
            currentPage++;
        }
    }

    public void UpdateCurrentPageDown()
    {
        if (currentPage > 0)
        {
            currentPage = 0;
        }
    }

    public void ToggleInteractivity(int i)
    {
        foreach (Button BTN in Pages)
        {
            BTN.interactable = false;
        }

        Pages[i].interactable = true;    
    }

    public void Update()
    {
        switch (currentPage)
        {
            case 4:

                break;
            case 3:

                break;
            case 2:
                ToggleInteractivity(2);
                break;
            case 1:
                ToggleInteractivity(1);
                break;
            case 0:
                ToggleInteractivity(0);
                break;
            default:

                break;

        }
    }
}
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: SetContinueMode Forcing Conversation to Auto Progress

Post by Tony Li »

Thanks. That looks fine to me. I no longer have a copy of your reproduction project. If you can't identify the issue, please feel free to send me a fresh reproduction project and provide the steps I should follow to reproduce the issue.
jae026
Posts: 51
Joined: Wed Apr 15, 2020 10:22 pm

Re: SetContinueMode Forcing Conversation to Auto Progress

Post by jae026 »

Tony, we had a lot of things to do since our last conversation but I was unable to figure out the issue. They also pointed out that the choices started at 2 in stead of 1 so you had to go left to see the first choice. I reuploaded a project. There is a scene called "Character Development" that plays a conversation on start that has the issue. The player is a prefab so any fixes will fix it across the board.
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: SetContinueMode Forcing Conversation to Auto Progress

Post by Tony Li »

Hi James,

Thanks. I'm downloading your repro project now and will investigate later today.
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: SetContinueMode Forcing Conversation to Auto Progress

Post by Tony Li »

Hi,

Although your Next and Prev buttons' OnClick events point to CurrentResponsePage, that script doesn't do anything. Still, update it in case you end up using it in the future. Change the first line in UpdateCurrentPageUp() to:

Code: Select all

var isNextResponseValid = (currentPage + 1) < DialogueManager.currentConversationState.pcResponses.Length && DialogueManager.currentConversationState.pcResponses[currentPage + 1].enabled;
This next step is the important one. Edit ScrollSnap.cs. Change the NextScreen() method to this:

Code: Select all

        public void NextScreen()
        {
            UpdateListItemPositions();

            var currentPage = CurrentPage();
            var isNextResponseValid = (currentPage + 1) < PixelCrushers.DialogueSystem.DialogueManager.currentConversationState.pcResponses.Length && PixelCrushers.DialogueSystem.DialogueManager.currentConversationState.pcResponses[currentPage + 1].enabled;

            if (CurrentPage() < _pages - 1 && isNextResponseValid)
            {
                _lerp = true;
                _lerpTarget = _pageAnchorPositions[CurrentPage() + 1];

                PageChanged(CurrentPage() + 1);
            }
        }
Finally, the buttons are showing in the correct order. It's just that the order in which you've arranged in the nodes on your canvas is misleading. Inspect the "What was that light?" node. You'll see that the actual order is:

jaeOrder.png
jaeOrder.png (23.47 KiB) Viewed 626 times

Use the up arrow button on the second node to reorder it before the first one.
jae026
Posts: 51
Joined: Wed Apr 15, 2020 10:22 pm

Re: SetContinueMode Forcing Conversation to Auto Progress

Post by jae026 »

Tony, I am having trouble getting the queststate from via script. IS this the best place to look.

PixelCrushers.DialogueSystem.QuestLog.IsQuestSuccessful(quest.questName);

Trying to set a bool based on the state. This for some reason returns unassigned
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: SetContinueMode Forcing Conversation to Auto Progress

Post by Tony Li »

Hi,

That's the correct API call. Make sure quest.questName matches the Name of a quest in your dialogue database.
jae026
Posts: 51
Joined: Wed Apr 15, 2020 10:22 pm

Re: SetContinueMode Forcing Conversation to Auto Progress

Post by jae026 »

It seems to not carry the Quest State from scene to scene in regards to Debugging the state. If I make make a conversation choice and a quest is then checked as successful in one scene it carries over fine in conversations.

However, when I run a debug check at the start of a level it returns the Quest State as "Active" even though dialogue that is reliant on the quest being successful recognizes it as being successful and works fine.

However, if I manually mark a quest as successful by default and run the check at start, it recognizes it as successful.

Below is my current code.

Code: Select all

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

[System.Serializable]
public class QuestStatus
{
    public string questName;
    public bool successful;
    public List<GameObject> QuestItem = new List<GameObject>();

    public QuestStatus(string s, bool b, List<GameObject> go)
    {
        this.questName = s;
        this.successful = b;
        this.QuestItem = go;
    }
}

public class ButterflyFXItems : MonoBehaviour
{
    [SerializeField]
    public List<QuestStatus> Quests = new List<QuestStatus>();

    private void OnEnable()
    {
        Lua.RegisterFunction("SetActiveQuestItem", this, SymbolExtensions.GetMethodInfo(() => SetActiveQuestItem(0)));
    }

    private void OnDisable()
    {
        Lua.UnregisterFunction("SetActiveQuestItem");
    }

    //Turn On Quest Items from Conversation Node 
    public void SetActiveQuestItem(double index)
    {
        int indexValue = (int)index;

        //Go through and turn on each item in the quest response item list
        foreach (GameObject item in Quests[indexValue].QuestItem)
        {

            Quests[indexValue].successful = true;

            //items do not exist
            if (item == null)
            {
                Debug.LogErrorFormat("Items for this quest are not populated. Please populate Quest Items in Butterfly FX Items for " + Quests[indexValue].questName);

                return;
            }
            else
            {
                item.SetActive(true);
            }
        }
    }

    //Reset All Quest Items to Default State (Off)
    public void ResetItemStates()
    {
        for (int i = 0; i < Quests.Count; i++)
        {
            Quests[i].successful = false;

            foreach (GameObject item in Quests[i].QuestItem)
            {
                if (item == null)
                {
                    return;
                }
                else
                {
                    item.SetActive(false);
                }
            }
        }
    }

    public void CheckAllQuestStates()
    {
        Debug.Log("Checking States");

        foreach (QuestStatus quest in Quests)
        {
            quest.successful = PixelCrushers.DialogueSystem.QuestLog.IsQuestSuccessful(quest.questName);

            Debug.Log(PixelCrushers.DialogueSystem.QuestLog.IsQuestSuccessful(quest.questName));

            Debug.Log("The quest : " + quest.questName + " is " + PixelCrushers.DialogueSystem.QuestLog.CurrentQuestState(quest.questName));


            if (!quest.successful)
            {
                foreach (GameObject item in quest.QuestItem)
                {
                    if (item == null)
                    {
                        return;
                    }
                    else
                    {
                        item.SetActive(false);
                    }
                }
            }
            else
            {
                foreach (GameObject item in quest.QuestItem)
                {
                    if (item == null)
                    {
                        return;
                    }
                    else
                    {
                        item.SetActive(true);
                    }
                }
            }
        }
    }
jae026
Posts: 51
Joined: Wed Apr 15, 2020 10:22 pm

Re: SetContinueMode Forcing Conversation to Auto Progress

Post by jae026 »

Also, the reason behind this is because I have items that exist in each scene that are set active based on different quest states. So I run a check at the start of each scene and turn on/off objects based on the quest states returned.
Post Reply