UI Panel's OnOpen or OnClose Action doesn't work after saved game loaded

Announcements, support questions, and discussion for Quest Machine.
Post Reply
LeeDongkun
Posts: 2
Joined: Tue Apr 09, 2019 4:36 pm

UI Panel's OnOpen or OnClose Action doesn't work after saved game loaded

Post by LeeDongkun »

Hi!
I gladly use your QuestMachine asset and SaveSystem asset. It's awesome.

but, I Have some problem

I added some custom action to UI Panel's OnOpen and OnClose action. because I need to Character unmoved and mouselocked.

But after I loaded saved game, these custom action doesn't work.
I have no idea why this happen.


and, why completed quest journal is cleared after I loaded my saved game?

Your save system saves quest automatically, but journal is cleared after load game.
This also I can't find out how to correct it.
User avatar
Tony Li
Posts: 22143
Joined: Thu Jul 18, 2013 1:27 pm

Re: UI Panel's OnOpen or OnClose Action doesn't work after saved game loaded

Post by Tony Li »

Hi,
LeeDongkun wrote: Tue Apr 09, 2019 4:42 pmI gladly use your QuestMachine asset and SaveSystem asset. It's awesome.
Thanks!
LeeDongkun wrote: Tue Apr 09, 2019 4:42 pmI added some custom action to UI Panel's OnOpen and OnClose action. because I need to Character unmoved and mouselocked.

But after I loaded saved game, these custom action doesn't work.
The Quest Machine GameObject survives scene changes. You added custom actions that point to your character. When you load a game, Unity unloads the original scene, including your character. The custom actions now don't point to anything. After unloading the original scene, Unity loads a new copy of the scene. But the custom actions still don't point to the character in the new copy of the scene because they were configured to point to the character in the original scene.

Here are three different solutions:

1. You can remove the Quest Machine GameObject's Dont Destroy GameObject component. This will load a new Quest Machine GameObject with the new copy of the scene. It's not as efficient because the new Quest Machine GameObject will need to initialize itself again, but it's an easy solution. If you use this solution, make sure the Save System is on a different GameObject, like in the Demo scene.

2. Or you can add a script to the Quest Machine GameObject that finds the player and locks/unlocks it. Configure your custom action to call this script.

3. Or, Quest Machine sends the message "Pause Player" when it opens the dialogue UI or journal UI. It sends the message "Unpause Player" when it closes the UI. You can update your character script when it receives these messages. See the demo's PlayerController2D.cs script for an example.

LeeDongkun wrote: Tue Apr 09, 2019 4:42 pmand, why completed quest journal is cleared after I loaded my saved game?
Check the Quest Journal's Save Settings. Try these settings:

Image
LeeDongkun
Posts: 2
Joined: Tue Apr 09, 2019 4:36 pm

Re: UI Panel's OnOpen or OnClose Action doesn't work after saved game loaded

Post by LeeDongkun »

Very Very Thank you
It works great!

:D
User avatar
Tony Li
Posts: 22143
Joined: Thu Jul 18, 2013 1:27 pm

Re: UI Panel's OnOpen or OnClose Action doesn't work after saved game loaded

Post by Tony Li »

Happy to help! :-)
Post Reply