You save the world... I'll save your game! Unity Serializer Released

After a huge amount of work by my beta testers I’ve decided that Unity Serializer is ready for version 1. Unity Serializer is a FREE save game manager that will store the state of your game so that a player can return later and continue from where they left off.

EDIT: Here is a video of US 2.2 being used to add save game functionality to AngryBots.

You can get Unity Serializer on the Asset Store, the latest documentation and versions are available on my website.

Great job on this!

Sweet!

Fantastic.

Might just be picking that up soon!

How would I handle objects that aren’t always there - for example, my game instances various enemies. Do I put them under a particular parent or something?

Version 1.04 has been released and is available on my website and the Asset Store shortly.

Sorry, for some reason I wasn’t getting responses to this thread. Any object you instance at run-time have either:

  • No parent
  • A parent flagged with (at least) a UniqueIdentifier

Objects created at runtime have the PrefabIdentifer script attached which handles their construction and that of any child objects in the prefab.

Awesome job! I can’t wait to try it out on my project!

Does your plugin use PlayerPrefs to eventually save the game to the hard disk or do you use some other method?

There’s a default implementation that uses PlayerPrefs but the core Serializer produces a compressed string so it is easy to store saved games anywhere including a server.

This is a maintenance release containing a few small fixes.

Version 1.05 5/9/12

[Fix] Error storing nulls in built-in string arrays
[Fix] connectedBody not being saved in joints

The new version of Unity Serializer is available and features:

  • JSON Support
  • Store game generated objects
  • New API for loading and saving individual objects

how do you save monobehaviour object? it is not serializable?

So Unity Serializer will serialize MonoBehaviours and references - are you asking how?

yes. i need to save and restore a monobehaviour object on design time, not the all game. i tried to examine your code, but it is so detailed so it will take long time to find how you did it. so could you tell the method(serialization?reflection?) to save it?

UnitySerializer will also serialize MonoBehaviours at edit time if you need it to. Subject to the scene having the requisite SaveGameManager and the components being decorated with storage scripts.

Here’s the simplest way I can think of - US does more than this. Basically if you don’t care about performance and references then you would reflect to find all the fields (and properties if you like). Perhaps then assign them to a Dictionary keyed off the name, then use BinaryFormatter to serialize the dictionary.

References

If this is always going to happen in the Editor then you could save references by detecting whether the property being saved is a GameObject or a Component and then save some special class to fix it up afterwards. For example you could use AssetDatabase.AssetPathToGUID to get the GUID of the associated GameObject in the project and then store the typename of the component you want to get on it. That doesn’t work so well for Scene items unfortunately where all you really have is the InstanceID - but that can change between sessions so would not be robust. If that doesn’t work for you then you haven’t got much choice more than updating the name of every component to be “unique” to that you can find it with its name path. US doesn’t do that (it adds a UniqueID component which you could also do), but the idea is sound (and it once worked that way, but its ugly).

This is amazing. I am creating a prefab in my game. How would I “Store Materials” and “Store Information” on it? How would I add that on the object in javascript?

This is a very good product. One question is this a DLL or source scripts. By the way is it C# or Unity Script?

Good job so far