Quest Not Going to Custom Quest Journal [Solved]

Announcements, support questions, and discussion for Quest Machine.
Luseya
Posts: 24
Joined: Mon May 29, 2023 6:02 pm

Quest Not Going to Custom Quest Journal [Solved]

Post by Luseya »

Hello!

I set up a simple quest and confirmed that it's working properly, but when I accept the quest from the NPC, I don't see it in the quest journal.

I read this thread already and made sure I dragged the UI component itself to the Quest Machine, and I believe I assigned everything else in the Quest Journal's Quest Journal UI component.

I also followed the instructions in this thread as well. And of course, I read through the manual. (Please let me know if there are any other resources pertaining to this topic and I can try figuring it out).

The main canvas shows up (like the text for Quest Journal, the scrollbar, and some other content I had there), but it looks like the active quest did not successfully go to the Quest Journal.

I do have a few errors, but I don't think they're related. I'll post them anyway just in case:
questmachine_errors.png
questmachine_errors.png (16.49 KiB) Viewed 1543 times

I'm also getting several warnings like this one:

SendMessage cannot be called during Awake, CheckConsistency, or OnValidate (Body Text Template: OnRectTransformDimensionsChange)
UnityEngine.UI.InputField:OnValidate ()

Here is the Quest Journal UI component. For the things that are missing, I intentionally excluded them because I don't intend to use them in my game. For example, the Player will not have the option to abandon a quest, so I just left those blank.
QuestJournalComponent.png
QuestJournalComponent.png (111.75 KiB) Viewed 1543 times
Please let me know if you need to see any other screenshots. Thank you so much!
Last edited by Luseya on Fri Jul 21, 2023 8:32 pm, edited 1 time in total.
User avatar
Tony Li
Posts: 22118
Joined: Thu Jul 18, 2013 1:27 pm

Re: Quest Not Going to Custom Quest Journal

Post by Tony Li »

Hi,
Luseya wrote: Mon Jul 17, 2023 11:18 pmI do have a few errors, but I don't think they're related.
Those errors are the issue. You must add UnityUIQuestButtonTemplate components to your quest name templates and assign their fields. Then assign those components to the UnityUIQuestJournalUI component. Please examine Quest Machine's example journal UI to see how it's set up. For example, this is how the Active Quest Name Template is set up:

activeQuestNameTemplate.png
activeQuestNameTemplate.png (245.46 KiB) Viewed 1540 times

The journal UI will use a copy of this Active Quest Name Template to show each quest's name.

Luseya wrote: Mon Jul 17, 2023 11:18 pmI'm also getting several warnings like this one:

SendMessage cannot be called during Awake, CheckConsistency, or OnValidate (Body Text Template: OnRectTransformDimensionsChange)
UnityEngine.UI.InputField:OnValidate ()
You can ignore that message. It's a bug in Unity. If I recall versions correctly, Unity introduced the bug in 2022. To prevent the warning message, inspect your dialogue UI and deactivate the child Text Field Panel. The Dialogue System will know to activate it at runtime when it's needed.


inputFieldBug.png
inputFieldBug.png (7.86 KiB) Viewed 1540 times
Luseya
Posts: 24
Joined: Mon May 29, 2023 6:02 pm

Re: Quest Not Going to Custom Quest Journal

Post by Luseya »

Thank you for the quick reply!

I added them in, but it's still not working. I think my issue is that my UI is more complex than the one in the demo, and I don't fully grasp what each component is supposed to do or what it's supposed to be assigned to. I tried looking through the manual as well as Youtube for this information but couldn't find it anywhere. So maybe I'm just not adding the right components to the right UI elements?

For example, the Active Quest Name Template was probably the most confusing for me. In the demo, it's a button with the name of the quest contained inside. In my project, the whole panel containing all the info for that quest is the button itself.

Below is a visual example of what I'm trying to do (pardon the appearance).
QuestListScreenshotExample.png
QuestListScreenshotExample.png (48.54 KiB) Viewed 1533 times
When clicked, that green box containing the quest info brings up a new panel with additional details. I assigned the Unity UI Quest Name Button Template and the Unity UI Button Template to this green panel button, but am I supposed to assign it instead to just the container of the quest name text? I tried that as well and it still didn't work, but my point is, it's things like that that are really confusing me with this. It would be helpful if the manual included some additional information about what each of these does. I tried following along with the one in the Dialogue System manual, but it's a bit different.

I have some other questions that might rule some things out.
1) I am integrating the Dialogue System with the Quest Machine. Do I need to use a Lua function to write the Journal text to the Quest Journal? If so, what would the Lua function be? I didn't see one in the Dialogue System support manual specifically for the Quest Journal.

2) I added the Journal text in the Quest Database using the Quest Editor. But in one of your videos, you mentioned that if you're integrating the Quest Machine with the Dialogue System, the text/dialogue in the Quest Editor would be ignored. I figured the journal text wouldn't be ignored since I didn't address it elsewhere in the Dialogue System, but was I wrong about that?
JournalTextScreenshot.png
JournalTextScreenshot.png (11.79 KiB) Viewed 1533 times
3) Because I'm not following the standard UI format (Selection Panel on the left, Details Panel on the right, etc.), will I have to use some custom scripting to get this to work or do you think the Quest Journal UI component can work as is with the design I have set up?

Sorry for the long post, but thank you so much for taking the time to help me with this!
User avatar
Tony Li
Posts: 22118
Joined: Thu Jul 18, 2013 1:27 pm

Re: Quest Not Going to Custom Quest Journal

Post by Tony Li »

Hi,

It will take a little scripting, but not much. Here's an example scene:

QM_CustomJournalUIExample_2023-07-19.unitypackage

On your journal UI, replace the UnityUIQuestJournalUI component with a subclass like this: (see: Replace in-place)

CustomQuestJournalUI.cs

Code: Select all

using UnityEngine;
namespace PixelCrushers.QuestMachine.Examples
{
    public class CustomQuestJournalUI : UnityUIQuestJournalUI
    {
        [SerializeField] private GameObject detailsPanel;

        protected override void RepaintSelectedQuest()
        {
            detailsPanel.SetActive(selectedQuest != null);
            base.RepaintSelectedQuest();
        }
    }
}
Replace your UnityUIQuestNameButtonTemplate components with a subclass like this:

CustomQuestNameButtonTemplate.cs

Code: Select all

using UnityEngine;
using UnityEngine.UI;

namespace PixelCrushers.QuestMachine.Examples
{
    public class CustomQuestNameButtonTemplate : UnityUIQuestNameButtonTemplate
    {
        [SerializeField] private UITextField questBodyText;
        [SerializeField] private UITextField questGiverName;
        [SerializeField] private Image questIcon;

        public override void Assign(Quest quest, ToggleChangedDelegate trackToggleDelegate)
        {
            base.Assign(quest, trackToggleDelegate);
            //-- What do you want to show? Journal text? Offer contents? Something custom?
            // var bodyContents = quest.GetContentList(QuestContentCategory.Journal);
            var bodyContents = quest.offerContentList;
            string bodyText = string.Empty;
            bodyContents.ForEach(content => bodyText += content.runtimeText);
            questBodyText.text = bodyText;
            questGiverName.text = StringField.GetStringValue(quest.questGiverID);
            questIcon.sprite = quest.icon;
        }
    }
}
These subclasses add new fields which you'll need to assign in the Inspector.

In the example, I expanded the Quest Selection Panel to fill the window, and I restyled the quest templates:

customJournalUI1.png
customJournalUI1.png (235.16 KiB) Viewed 1531 times

The Quest Details Panel also fills the window, but it's only visible when a quest is selected. The little "X" in the upper right of the Details Panel closes it.

customJournalUI2.png
customJournalUI2.png (249.11 KiB) Viewed 1531 times

You'll also probably want to modify these scripts to do any extra stuff you want your journal UI to support.
Luseya
Posts: 24
Joined: Mon May 29, 2023 6:02 pm

Re: Quest Not Going to Custom Quest Journal

Post by Luseya »

Thank you so much for taking the time to set up the sample scene and explain everything.

I set everything up exactly as you instructed, but the active quest is still not going to the Quest Journal :(

Could it have anything to do with the other questions I mentioned in my last post?
User avatar
Tony Li
Posts: 22118
Joined: Thu Jul 18, 2013 1:27 pm

Re: Quest Not Going to Custom Quest Journal

Post by Tony Li »

Hi,

When you accept the quest, if you inspect the player's Quest Journal component is it in the Quests list?

This will tell us if the quest isn't getting int othe Quest Journal at all, or if it's there but it isn't showing in the Quest Journal UI.

Also, does the example scene above work correctly in your project?
Luseya
Posts: 24
Joined: Mon May 29, 2023 6:02 pm

Re: Quest Not Going to Custom Quest Journal

Post by Luseya »

Yup, the quest appears in the Quests List.

I opened the example scene you sent me in a separate project that I use for samples like this and it worked correctly!
User avatar
Tony Li
Posts: 22118
Joined: Thu Jul 18, 2013 1:27 pm

Re: Quest Not Going to Custom Quest Journal

Post by Tony Li »

Great! We know that the quest is actually in the Quest Journal. Your Quest Journal UI just isn't showing it.

Are you opening the Quest Journal UI by calling the Quest Journal component's QuestJournal.ToggleJournalUI() or ShowJournalUI() methods?

Can you compare your UI to the example one? Are there any errors or warnings in the Console window? Maybe you need to assign fields to the UI's fields, such as the Active Quest Name Template field.

If that doesn't help, please feel free to send a reproduction project to tony (at) pixelcrushers.com
Luseya
Posts: 24
Joined: Mon May 29, 2023 6:02 pm

Re: Quest Not Going to Custom Quest Journal

Post by Luseya »

Yeah I checked all of those things and everything seems to be fine to me. :(

I'll send you my project then. So sorry this is taking so much of your time! T^T
Luseya
Posts: 24
Joined: Mon May 29, 2023 6:02 pm

Re: Quest Not Going to Custom Quest Journal

Post by Luseya »

Okay actually, I think I sorted most of it out, except for one last thing. Mostly everything is showing up now: the Quest Title, Quest Giver's Name, and Quest Giver's Portrait, but the only thing that's not showing up is the quest body text. The WEIRD thing is that the body text shows up in the details panel but not in the Active Quest Name Template.

I have both the title text and body text as children of the Active Quest Name Template:
ActiveQuestNameTemplate_Hierarchy.png
ActiveQuestNameTemplate_Hierarchy.png (6.12 KiB) Viewed 1515 times

Here is a screenshot of the Active Quest Name Template's components, including the custom script you provided:
ActiveQuestNameTemplate_Components.png
ActiveQuestNameTemplate_Components.png (46.64 KiB) Viewed 1515 times

And here is a screenshot of the Journal Text in the Quest Editor.
JournalTextScreenshot.png
JournalTextScreenshot.png (10.48 KiB) Viewed 1515 times

Do you know why the body text would show up in the Details Panel but not the Selection Panel in the Active Quest Name Template? And why all the other children of the Active Quest Name Template are showing up but not the body text?

Thank you again for all your help!
Post Reply