ToggleJournalUI() Error

Announcements, support questions, and discussion for Quest Machine.
Post Reply
DebugJk
Posts: 10
Joined: Sun May 28, 2023 2:46 am

ToggleJournalUI() Error

Post 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");
User avatar
Tony Li
Posts: 22093
Joined: Thu Jul 18, 2013 1:27 pm

Re: ToggleJournalUI() Error

Post 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");
DebugJk
Posts: 10
Joined: Sun May 28, 2023 2:46 am

Re: ToggleJournalUI() Error

Post by DebugJk »

I was gonna do what you said
There's nothing I can put in the Quest Machine Configuration > Quest Journal UI
Attachments
20230725_230006.png
20230725_230006.png (51.28 KiB) Viewed 1294 times
User avatar
Tony Li
Posts: 22093
Joined: Thu Jul 18, 2013 1:27 pm

Re: ToggleJournalUI() Error

Post by Tony Li »

Hi,

It looks like a journal UI is already assigned:

assignJournalUI.png
assignJournalUI.png (46.98 KiB) Viewed 1292 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.
DebugJk
Posts: 10
Joined: Sun May 28, 2023 2:46 am

Re: ToggleJournalUI() Error

Post by DebugJk »

Quest Journal object have Unity Ui Quest Journal UI and UIPanel components
But the problem hasn't been solved yet
Attachments
20230725_230006.png
20230725_230006.png (35.79 KiB) Viewed 1287 times
20230725_231505.png
20230725_231505.png (34.44 KiB) Viewed 1291 times
User avatar
Tony Li
Posts: 22093
Joined: Thu Jul 18, 2013 1:27 pm

Re: ToggleJournalUI() Error

Post 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?
DebugJk
Posts: 10
Joined: Sun May 28, 2023 2:46 am

Re: ToggleJournalUI() Error

Post by DebugJk »

Yes, The same error occurs in the demo scene.
DebugJk
Posts: 10
Joined: Sun May 28, 2023 2:46 am

Re: ToggleJournalUI() Error

Post 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
User avatar
Tony Li
Posts: 22093
Joined: Thu Jul 18, 2013 1:27 pm

Re: ToggleJournalUI() Error

Post by Tony Li »

Hi,

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