Advertisement Jump to content
Sign in to follow this  
rpiller

Unity Unity save game

This topic is 1826 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I know the technical ways to save a game, but I'm more wondering when/how, in Unity, would you save game data about so many different entities when each has their own script that controls it. Also about dynamic objects that are created at run-time.

 

I've seen people make a save game script, but how is that script going to know what entities it needs to save? Making parameters that you have to pass everything you want to save from the editor into doesn't seem like a very good way to do this. At some level it almost seems like you'd want to inform every script/game object to save itself when, say, the same button is pressed. Any ideas around this?

Share this post


Link to post
Share on other sites
Advertisement

You could create a class called that derives Monobehaviour and has virtual functions to save/load to a file.

Now let all your object derive from that class and when you want to save/load use FindObjectOfType to get all objects that derive from that class.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!