Quest Close Button

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
jrose1184
Posts: 62
Joined: Mon Jan 22, 2024 2:35 pm

Quest Close Button

Post by jrose1184 »

i Tony,

Do you have a helper class for calling the close quest button.

Im using a controller but i need to so somthing when i close it.

i.e EventSystem.current.SetSelectedGameObject(buttons[0].gameObject);

Im not sure how to do this as im not modifing your script.
User avatar
Tony Li
Posts: 22886
Joined: Thu Jul 18, 2013 1:27 pm

Re: Quest Close Button

Post by Tony Li »

Hi,

You can write a simple script that calls:

Code: Select all

PixelCrushers.GameObjectUtility.FindFirstObjectByType<PixelCrushers.DialogueSystem.QuestLogWindow>().Close();
Or add a QuestLogWindowHotkey component to your button and connect the OnClick() event to its ToggleQuestLogWindow() method. This method will close the quest log window if it's open, or open it if it's closed.
jrose1184
Posts: 62
Joined: Mon Jan 22, 2024 2:35 pm

Re: Quest Close Button

Post by jrose1184 »

Thanks,

Unless im not understanding correctly i need a listen event to know when that button has been closed so i can do somthing on another script.
jrose1184
Posts: 62
Joined: Mon Jan 22, 2024 2:35 pm

Re: Quest Close Button

Post by jrose1184 »

I might close the button with a mouse click of input.getbutton.
User avatar
Tony Li
Posts: 22886
Joined: Thu Jul 18, 2013 1:27 pm

Re: Quest Close Button

Post by Tony Li »

If you need to know when the quest log window has closed, you can hook into the OnClose() UnityEvent.
jrose1184
Posts: 62
Joined: Mon Jan 22, 2024 2:35 pm

Re: Quest Close Button

Post by jrose1184 »

Code: Select all


public QuestLogWindow questLogWindow;

 void OnDestroy()
    {
        if (questLogWindow != null)
        {
            questLogWindow.OnClose.RemoveListener(OnQuestLogClosed);
        }
    }
    
        private void Start()
    {
        if (questLogWindow != null)
        {
            questLogWindow.OnClose.AddListener(OnQuestLogClosed);
        }
    }
    
Hi can you tell me where the onclose is cling from please as wuestLogWindow.OnClose has no event. it throws a 'Cannot resolve symbol 'OnClose''
User avatar
Tony Li
Posts: 22886
Joined: Thu Jul 18, 2013 1:27 pm

Re: Quest Close Button

Post by Tony Li »

Hi,

If you're connecting it in C# code, it's StandardUIQuestLogWindow.onClose with a lowercase 'o':

Code: Select all

questLogWindow.onClose.AddListener(OnQuestLogClosed);
...
questLogWindow.onClose.RemoveListener(OnQuestLogClosed);
It appears in the inspector as OnClose().
jrose1184
Posts: 62
Joined: Mon Jan 22, 2024 2:35 pm

Re: Quest Close Button

Post by jrose1184 »

Thanks Tony
User avatar
Tony Li
Posts: 22886
Joined: Thu Jul 18, 2013 1:27 pm

Re: Quest Close Button

Post by Tony Li »

Glad to help!
Post Reply