Page 1 of 1

Change Active Quest Selection With Script

Posted: Thu Oct 01, 2020 5:03 pm
by Rhaelix
Hello,

We have implemented Quest Machine into our project and have been running with it for a while. However, we are adding new features that trigger events through script and not user input. I am attempting to figure out how to change the currently selected "Active Quest" in the opened Quest Journal through script, instead of mouse input. If I can nail down the function that is called to pass the item's array ID to the change function that displays newly selected Active Quest details on the right and changes the highlighted Active on the left, I should be able to handle the rest.

Thanks in advance!

Re: Change Active Quest Selection With Script

Posted: Thu Oct 01, 2020 9:47 pm
by Tony Li
Hi,

The UnityUIQuestJournalUI has a protected property selectedQuest:

Code: Select all

protected Quest selectedQuest { get; set; }
You can make a subclass of UnityUIQuestJournalUI and add a method to set selectedQuest and repaint the UI:

Code: Select all

public class MyQuestJournalUI : UnityUIQuestJournalUI
{
    public SelectQuest(Quest quest)
    {
        selectedQuest = quest;
        Repaint();
    }
    
    // Alternate version:
    public SelectQuest(int i)
    {
        if (questJournal != null && 0 <= i && i < questJournal.questList.Count)
        {
            selectedQuest = questJournal.questList[i];
            Repaint();
        }
    }
}

Re: Change Active Quest Selection With Script

Posted: Mon Oct 05, 2020 12:11 pm
by Rhaelix
This is more than I expected, Tony. You have the best product support and always go above and beyond.

Re: Change Active Quest Selection With Script

Posted: Mon Oct 05, 2020 1:03 pm
by Tony Li
Thanks! Glad to help!

Note: I typed the example above directly into my reply. It's missing niceties such as "using" statements at the top, and it may have typos.