moving canvas out of dialogue manager prefab hierarchy

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
lemonjolly_anna
Posts: 17
Joined: Tue May 16, 2023 11:41 pm

moving canvas out of dialogue manager prefab hierarchy

Post by lemonjolly_anna »

hello!

is it possible to move the Canvas child object from the DialogueManager prefab?
When I tried, the conversations wouldn't play anymore.
Screenshot 2023-06-12 140402.jpg
Screenshot 2023-06-12 140402.jpg (136.35 KiB) Viewed 312 times
User avatar
Tony Li
Posts: 21679
Joined: Thu Jul 18, 2013 1:27 pm

Re: moving canvas out of dialogue manager prefab hierarchy

Post by Tony Li »

It's fine to move the canvas out of the Dialogue Manager GameObject if your game is contained in one scene. The Dialogue Manager is a persistent singleton. This, and its repercussions, are explained in How To: Manage Player Controls and Scene Changes.

What's the reason for moving the canvas? I may be able to suggest a better solution.
lemonjolly_anna
Posts: 17
Joined: Tue May 16, 2023 11:41 pm

Re: moving canvas out of dialogue manager prefab hierarchy

Post by lemonjolly_anna »

I'm moving it to under a UIManager object which is also a peristent singleton - not sure if that helps!

The reasoning is mostly just for keeping track of things, and being able to easily reference all the canvas active in a scene via the UIManager!
User avatar
Tony Li
Posts: 21679
Joined: Thu Jul 18, 2013 1:27 pm

Re: moving canvas out of dialogue manager prefab hierarchy

Post by Tony Li »

That's fine then. As long as they're both persistent singletons, they'll stay in sync.
lemonjolly_anna
Posts: 17
Joined: Tue May 16, 2023 11:41 pm

Re: moving canvas out of dialogue manager prefab hierarchy

Post by lemonjolly_anna »

I see! For some reason though, the conversations won't play if I move the canvas out of dialogue manager's hierarchy?

Is it because it breaks the prefab or some other connection?
User avatar
Tony Li
Posts: 21679
Joined: Thu Jul 18, 2013 1:27 pm

Re: moving canvas out of dialogue manager prefab hierarchy

Post by Tony Li »

Yes, almost certainly. The Dialogue Manager survives scene changes. If it points to GameObjects that do not also survive scene changes, those references will become invalid. Related info here: How To: Manage Player Controls and Scene Changes
lemonjolly_anna
Posts: 17
Joined: Tue May 16, 2023 11:41 pm

Re: moving canvas out of dialogue manager prefab hierarchy

Post by lemonjolly_anna »

But the canvas does persist across scenes? As in I'm moving the canvas from under the DialogueManager (singleton) to under UIManager (singleton).
User avatar
Tony Li
Posts: 21679
Joined: Thu Jul 18, 2013 1:27 pm

Re: moving canvas out of dialogue manager prefab hierarchy

Post by Tony Li »

Hi,

I can't say without more information. When you enter play mode, does the Dialogue Manager's Display Settings > Dialogue UI field still point to a valid dialogue UI?

And when you change scenes, does it still point to a valid dialogue UI?

If so, then are there any errors or warnings in the Console window when you try to start a conversation?
Post Reply