Advice on Saving a Player with Ships and Inventory

Discussion and help for Easy Save 3
Post Reply
Tanoshimi
Posts: 11
Joined: Thu Oct 07, 2021 4:25 pm

Advice on Saving a Player with Ships and Inventory

Post by Tanoshimi »

So, I have a Player and they have a list of ships they customize.

Currently, I'm manually writing the number of ships, and then looping through and for each ship reading/writing the specifics about that ship (which prefab it is, the name, the stats, the color of each material in it).

I was looking to see if I could just save the materials instead, but now I'm wondering if there's a way I can just save a Ship? Or even a Player, that contains an unknown number of Ships?

What is the best practice for storing a Player and all of their ships, and inventory?
User avatar
Joel
Moodkie Staff
Posts: 4846
Joined: Wed Nov 07, 2012 10:32 pm

Re: Advice on Saving a Player with Ships and Inventory

Post by Joel »

Hi there,

If your ship is represented as a class/script, you can simply save that class. For information on what fields of classes can be serialized, please see this guide:
http://docs.moodkie.com/easy-save-3/es3 ... ted-types/

If your ship is a GameObject, you can find information on saving these here:
https://docs.moodkie.com/easy-save-3/es ... s-prefabs/

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Tanoshimi
Posts: 11
Joined: Thu Oct 07, 2021 4:25 pm

Re: Advice on Saving a Player with Ships and Inventory

Post by Tanoshimi »

So the Player is a script/class I made, and a Ship is a prefab gameobject with a script that has all of the settings. So, to save a ship, I need to store:
- GameObject or prefab, or at least which Prefab is used
- Materials that may have been changed
- The Class that stores the stats on the ship (speed, turning radius, armor, etc)

These items have not be serialized but are public variables. If I change them all to serialized variables then I can save that class? But you say I can save a GameObject/Prefab. So can I just save the entire GameObject/Prefab to include that Class script that has the stats and the materials that are stored in the GameObject?

I'm a developer by nature, so I'm just a bit confused.
User avatar
Joel
Moodkie Staff
Posts: 4846
Joined: Wed Nov 07, 2012 10:32 pm

Re: Advice on Saving a Player with Ships and Inventory

Post by Joel »

You could save the script itself, or the GameObject which contains the script: whichever makes more sense in your project.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Post Reply