By default, the Dialogue Manager GameObject survives scene changes. (Its Other Settings > Don't Destroy On Load and Allow Only One Instance checkboxes are ticked.) This behavior is called a "persistent singleton".
Don't assign references between persistent singletons and regular, non-persistent GameObjects in scenes. In the screenshot below, the Dialogue Manager is a persistent singleton, and the Player GameObject is a regular GameObject:
(Don't do this.)
Dialogue System messages such as "OnConversationStart" and "OnConversationEnd" are sent to the Dialogue Manager GameObject and the conversation's primary actor and conversant. (See this table.)
Let's say you've also configured another scene:
(Don't do this.)
Those scenes will play fine individually in the Unity editor's play mode. However, the Dialogue Manager from Scene 1 (or whatever scene you start in) will survive scene changes. When you change scenes, the surviving Dialogue Manager's Dialogue System Events component won't be pointing to the correct Player:
One common solution is to move the Dialogue Manager Events to the Player GameObject:
This assumes the Player is configured as the conversation's Actor:
and that the Dialogue System Trigger's Conversation Actor field is blank:
(See Character GameObject Assignments for details on how GameObjects are associated with actors in your dialogue database.)
Side note: Be careful when assigning references to prefab assets, too. If the Dialogue Manager and the prefab are all part of the same hierarchy that gets instantiated at the same time, Unity will update the reference to point to the scene instance. Otherwise, the reference will still point to the prefab version that's in the Project view, not the instance in the scene. For example, if you've pointed the Dialogue Manager's OnConversationStart() event to a player prefab, it will try to run SimpleController.enabled = false on the prefab, not the actual instance in the scene.
[HOWTO] How To: Manage Player Controls and Scene Changes
-
- Posts: 10
- Joined: Fri Oct 06, 2023 10:54 am
Re: [HOWTO] How To: Manage Player Controls and Scene Changes
It helps! Thank you!
-
- Posts: 4
- Joined: Sat Aug 26, 2023 4:45 am
Re: [HOWTO] How To: Manage Player Controls and Scene Changes
In other words, is it correct to tell the Player to manage the status independently by assigning an Actor and Events to the Player itself, without having to touch the Player's events in Dialog Manager every Scene?
The picture below is what I understand.
The picture below is what I understand.
- Attachments
-
- Understand.png (107.86 KiB) Viewed 861 times
Re: [HOWTO] How To: Manage Player Controls and Scene Changes
Yes, exactly. Your images demonstrate it well. You can also see an example in the Interaction Tutorial at 07:00: