Page 1 of 1

ToggleJournalUI() Error

Posted: Mon Jul 24, 2023 11:42 pm
by DebugJk
if(Input.GetKeyDown(KeyCode.J))
{
QuestMachine.GetQuestJournal().ToggleJournalUI();
}


I tried to see the quest journal when the J key was pressed, but I got this error

MissingReferenceException: The object of type 'UnityUIQuestJournalUI' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
UnityEngine.Component.GetComponent[T] () (at <24d45e813e524a99bfb7a145158a7980>:0)
PixelCrushers.QuestMachine.UnityUIBaseUI.Show ()

i tried ShowJournalUI() too.

++

Can i check Npc have a quest?
I want the code on the bottom to run if Npc doesn't have quests what should I type in A?
A is check npc have a quest


for example)

if( A )
{
return;
}
Debug.Log("Npc dont have quest");

Re: ToggleJournalUI() Error

Posted: Tue Jul 25, 2023 8:21 am
by Tony Li
Hi,
DebugJk wrote: Mon Jul 24, 2023 11:42 pmI tried to see the quest journal when the J key was pressed, but I got this error

MissingReferenceException: The object of type 'UnityUIQuestJournalUI' has been destroyed but you are still trying to access it.
Make sure a valid journal UI is assigned to the Quest Machine GameObject's Quest Machine Configuration > Quest Journal UI field. It's easiest if this journal UI is a child of the Quest Machine GameObject (e.g., in its Canvas).

Leave the player's Quest Journal component's Quest Journal UI field unassigned.
DebugJk wrote: Mon Jul 24, 2023 11:42 pmCan i check Npc have a quest?
I want the code on the bottom to run if Npc doesn't have quests what should I type in A?
Check QuestGiver.HasOfferableOrActiveQuest():

Code: Select all

QuestGiver questGiver = this.gameObject.GetComponent<QuestGiver>();
if( questGiver.HasOfferableOrActiveQuest() )
{
   return;
}
Debug.Log("Npc dont have quest");

Re: ToggleJournalUI() Error

Posted: Tue Jul 25, 2023 10:02 am
by DebugJk
I was gonna do what you said
There's nothing I can put in the Quest Machine Configuration > Quest Journal UI

Re: ToggleJournalUI() Error

Posted: Tue Jul 25, 2023 10:10 am
by Tony Li
Hi,

It looks like a journal UI is already assigned:

assignJournalUI.png
assignJournalUI.png (46.98 KiB) Viewed 1289 times

If you want to assign a different one, you will have to drag it into the field. Don't use the circle target in this case.

Make sure no journal UI is assigned to the QuestJournal component.

Re: ToggleJournalUI() Error

Posted: Tue Jul 25, 2023 10:16 am
by DebugJk
Quest Journal object have Unity Ui Quest Journal UI and UIPanel components
But the problem hasn't been solved yet

Re: ToggleJournalUI() Error

Posted: Tue Jul 25, 2023 10:32 am
by Tony Li
Does the Demo scene work properly in your project?

If so, please play your scene in the editor. Just before pressing the 'J' key, inspect the Quest Machine GameObject. Is the Quest Journal UI field still assigned correctly? Is the Quest Journal component's UI Settings > Quest Journal UI field unassigned?

Re: ToggleJournalUI() Error

Posted: Tue Jul 25, 2023 10:38 am
by DebugJk
Yes, The same error occurs in the demo scene.

Re: ToggleJournalUI() Error

Posted: Tue Jul 25, 2023 10:40 am
by DebugJk
Oh i solved the problem

After removing the imported quest machine completely and repeating the import again, the problem was solved
I'm sorry to bother you

Re: ToggleJournalUI() Error

Posted: Tue Jul 25, 2023 11:38 am
by Tony Li
Hi,

No worries -- I'm glad it's working now!