Savers on start scene

Announcements, support questions, and discussion for Quest Machine.
GorkaGames
Posts: 178
Joined: Fri Sep 21, 2018 8:38 pm

Savers on start scene

Post by GorkaGames »

Hi,

I know the the GameObjects where the Savers are attached, must be Active in order to work.
BUT, the GameObjects where the Savers are attached, must be Active on the First Frame when the Scene Loads?

Or do they work as soon as you .setactive(true) to them?

Quite confusing here:
https://docs.unity3d.com/Manual/ExecutionOrder.html

Is it the same for all of them? Position, active, destroy, custom with templates, etc...
User avatar
Tony Li
Posts: 22104
Joined: Thu Jul 18, 2013 1:27 pm

Re: Savers on start scene

Post by Tony Li »

Hi,

They must be active when the Save System tells the Savers to apply their saved data. (They do not work as soon as you set them active. They only work when the Save System tells them to apply their saved data.)

After loading a scene, the Save System will wait a number of frames. Then it will tell all active Savers to apply their saved data. Set the Save System's Frames To Wait Before Apply Data to specify the number of frames.

For example, let's say the player GameObject does not] exist in the scene. Instead, when the scene starts, a script in the scene instantiates the player from a prefab. The prefab has a Position Saver component.

In the first frame, the script instantiates the player. In the second frame, the player runs its Start() method to initialize itself.

In this case, you should set Frames To Wait Before Apply Data to 2. This gives the player time to become ready to apply its saved data.

Active Saver is a unique case. If the target GameObject starts inactive, Active Saver should be on a different, active GameObject. Otherwise the Save System won't tell it to apply data (i.e., set the target active/inactive).
GorkaGames
Posts: 178
Joined: Fri Sep 21, 2018 8:38 pm

Re: Savers on start scene

Post by GorkaGames »

Thanks for the detailed explanation, as always.

So then, relating to : Active Saver is a unique case. If the target GameObject starts inactive, Active Saver should be on a different, active GameObject. Otherwise the Save System won't tell it to apply data (i.e., set the target active/inactive)

If I have a active Game Object targeting an Enemy that starts inactive, once gets active (because the active saver tells it), do the Position and Destructive Savers for that enemy work? As I guess there are 1 frame of difference and as you said: (They do not work as soon as you set them active. They only work when the Save System tells them to apply their saved data.).....

Sorry if I insist but the Position and destructive Savers are working for me only when they are active from the beginning, when the scene starts, not if some active saver is telling them to activate.

:)
User avatar
Tony Li
Posts: 22104
Joined: Thu Jul 18, 2013 1:27 pm

Re: Savers on start scene

Post by Tony Li »

GorkaGames wrote: Wed Oct 17, 2018 8:03 am If I have a active Game Object targeting an Enemy that starts inactive, once gets active (because the active saver tells it), do the Position and Destructive Savers for that enemy work?
Good catch! I hadn't considered that case. It doesn't work that way yet. If the GameObject starts inactive, then any Savers on it will not apply their data. I will add this. If the Active Saver activates a GameObject, it will also tell all of the GameObject's Savers to apply their data.
GorkaGames
Posts: 178
Joined: Fri Sep 21, 2018 8:38 pm

Re: Savers on start scene

Post by GorkaGames »

Great!
User avatar
Tony Li
Posts: 22104
Joined: Thu Jul 18, 2013 1:27 pm

Re: Savers on start scene

Post by Tony Li »

Here is the updated ActiveSaver component: ActiveSaver_2018-10-17.unitypackage
GorkaGames
Posts: 178
Joined: Fri Sep 21, 2018 8:38 pm

Re: Savers on start scene

Post by GorkaGames »

Thanks, I didn't test it on my main Project, but from here I see the following error:
currentSavedGameData

"SaveSystem" doesn't contain a definition for "currentSavedGameData"
Just in case....

I see you use "GetComponentsInChildren<Saver>" , so it can work for the enemies down the tree on a folder's tree structure? And not just the main children? Just to know....
User avatar
Tony Li
Posts: 22104
Joined: Thu Jul 18, 2013 1:27 pm

Re: Savers on start scene

Post by Tony Li »

GorkaGames wrote: Wed Oct 17, 2018 11:51 amThanks, I didn't test it on my main Project, but from here I see the following error:
currentSavedGameData

"SaveSystem" doesn't contain a definition for "currentSavedGameData"
The updated ActiveSaver takes advantage of a new property in 1.0.8. If you import 1.0.8b1, the error will disappear.
GorkaGames wrote: Wed Oct 17, 2018 11:51 amI see you use "GetComponentsInChildren<Saver>" , so it can work for the enemies down the tree on a folder's tree structure? And not just the main children? Just to know....
Yes, that's correct.
GorkaGames
Posts: 178
Joined: Fri Sep 21, 2018 8:38 pm

Re: Savers on start scene

Post by GorkaGames »

Testing now the savers after importing the beta.

I don't see the random key, is it behind the scenes? If so, we don't fill anything on the key?
User avatar
Tony Li
Posts: 22104
Joined: Thu Jul 18, 2013 1:27 pm

Re: Savers on start scene

Post by Tony Li »

GorkaGames wrote: Wed Oct 17, 2018 7:27 pm Testing now the savers after importing the beta.

I don't see the random key, is it behind the scenes? If so, we don't fill anything on the key?
Select menu item Tools > Pixel Crushers > Common > Save System > Assign Unique Keys.... This will assign unique keys to every Saver whose Key field is blank.
Post Reply