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

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Japtor
Posts: 120
Joined: Thu Jun 28, 2018 1:41 pm

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

Post 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.
Last edited by Japtor on Thu Jul 05, 2018 3:59 am, edited 1 time in total.
User avatar
Tony Li
Posts: 22058
Joined: Thu Jul 18, 2013 1:27 pm

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

Post 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;
        }
    }
}
Japtor
Posts: 120
Joined: Thu Jun 28, 2018 1:41 pm

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

Post by Japtor »

Hi!

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

Regards,
Javier.
User avatar
Tony Li
Posts: 22058
Joined: Thu Jul 18, 2013 1:27 pm

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

Post by Tony Li »

Happy to help!
Post Reply