Page 1 of 1

[Solved] Can you add new UI prefabs to the Dialogue Manager -> Instantiate Prefabs?

Posted: Tue Jul 03, 2018 1:58 pm
by Japtor
Hi all!

In the Dialogue Manager -> Instantiate Prefabs -> Prefabs... Can you add new UI elements that have nothing to do with dialogues/quests, like pause menus? Additionally, If I add it there, is there a way to access it and try to, for example, activate the menu or deactivate it?

Thanks.

Regards,
Javier.

Re: Can you add new UI prefabs to the Dialogue Manager -> Instantiate Prefabs?

Posted: Tue Jul 03, 2018 2:25 pm
by Tony Li
Hi Javier,

Yes, you can add more prefabs to that Instantiate Prefabs component. They will be added as children to the Dialogue Manager's Canvas. You can also add more Instantiate Prefabs components if you want to instantiate them as children of a different canvas or GameObject.

The Dialogue System doesn't provide anything in specific to access them. Just treat them like any GameObject that's instantiated from a prefab. For example, you could make the prefab GameObject active and its child panel inactive. Add a script to the prefab GameObject that toggles the panel on and off when the player presses Escape:

Code: Select all

using UnityEngine;

public class PauseMenu : MonoBehaviour
{
    public GameObject panel;
    
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            panel.SetActive(!panel.activeSelf);
            Time.timeScale = panel.activeSelf ? 1 : 0;
        }
    }
}

Re: Can you add new UI prefabs to the Dialogue Manager -> Instantiate Prefabs?

Posted: Thu Jul 05, 2018 3:58 am
by Japtor
Hi!

Thanks for the answer! It helped me a lot :)

Regards,
Javier.

Re: [Solved] Can you add new UI prefabs to the Dialogue Manager -> Instantiate Prefabs?

Posted: Thu Jul 05, 2018 8:26 am
by Tony Li
Happy to help!