Save Room Objects And Positioning To a File and Load Them on Room Start

Hi, Im looking for a way to save all ovjects in a room to a file and then load those objects from a file. i thought of creating an objID stsyem that would save a player pref of objID.position.x & objID.position.z. and the using something like PlayerPrefs.SetFloat (objID + “x”, objID.position.x). and then try to instaniate them on room load.

Im sure there is a better and more efficient way to do this but I havent found any threads about in via Google search.

Any thoughts or good threads to point me too?

Don’t use PlayerPrefs to store such large amount of data. PlayerPrefs is stored in the registry on windows… this is an obtuse amount of data to be putting in there.

This is called serialization.

Unity has built in serialization support. The kind available at runtime is json serialization and is accessed via the ‘JsonUtility’:

You can also do binary, xml, or any other kind of serialization you want manually (you’d have to write it all yourself).

Take said resulting serialized data and save it to a file somewhere. The persistentDataPath is a good place:

What you’ll want is to create a serializable class that is a token of the various objects you will be saving, serialize the collection of them, and stick them in that path.

I’m storing a MASSIVE amount of this kind of data for our game, and I am going to give SQLITE a whirl. I will let you know how it goes later.