Unity Serializer: Load & Save your Game (for free!)


PLEASE COMMENT ON THE ROADMAP FOR Unity Serializer – available here.

Preferred Download

The latest version available on the Asset Store is 0.965

Other downloads

Download   Latest download (0.965) :

Download (320MB) Test/complex project (for v0.6):

Latest Versions:(no examples)

Download 0.965 – Release Candidate, fixes (see notes)

Download 0.951 – Rigidbodies, fixes (see notes)

Download 0.941 – Fixes (see notes)

Download 0.93 – DontDestroyOnLoad, prefabs (see notes)

Download 0.92 – exception handling (see notes)

Download 0.91 – PREFABS (see notes)

Download 0.9 – prefabs, advanced (see notes)

Download 0.84 – script materials & textures (see notes)

Download 0.8 – fixes, reference wizard (see notes)

Add Ons (available in main install from v0.965)

Download(New extended) PlayMaker Support (experimental)

DownloadiTween Support (experimental) v0.6 required

Unity Serializer is free for you to use, but if you would like to support the project (and help me cover my hosting fees!) then you can do so with the PayPal link above.

Introduction

UnitySerializer is a full level serialisation plug in.  It enables you to save the progress of a game and restore it at some point in the future.  It does this with minimal impact on the design of your game and requires minimal modification to your behaviours and classes.

Platforms

Works on all Unity runtime platforms including IOS and Droid.

Features

The serializer supports storing newly instantiated prefabs, as well as the status of existing scene objects (such as those that might be destroyed during the course of a game).

UnitySerializer supports the serialization of your custom classes, fields and properties including things like generic collections of complex objects as well as standard Unity components including

  • Animation support
  • Rigidbody support
  • Materials & Textures (references and programmatically generated)
  • Support for NavMeshAgent
  • Transform – including parent/child relationships
In addition, presuming you use my extended coroutine start functions, all of your coroutines will continue executing from the point that they left off and will be restored with all local variables intact. You need make no changes to your coroutines – just to the way that you start them.

The status of your level is stored in a string which can be placed in PlayerPrefs – stored on a server or in a file.

For those interested in the details of extending the serialization methods, some advanced features or for those who would consider contributing to the project there is a technical discussion of the serialisation implementation available here.

THIS PROJECT IS CURRENTLY IN BETA STATUS – IT’S WORKING FINE FOR MY GAME – PLEASE REPORT ALL BUGS.

YOU ARE LICENSED TO USE THIS CODE FOR ANY PURPOSE – THERE ARE NO WARRANTIES EXPRESSED OR IMPLIED. MIT LICENSE. USE AS YOU SEE FIT.  If you use this in a commercial project or are a professional studio I would appreciate a donation – it is not required – but bug reports from supporters will be prioritised.  If you use this code as part of another framework that you distribute please add a link to this page and a credit to me as the author of that section.

Please email me if you wish to contribute time to this project.

Demo (new version on 24/6/12) – Save game for Angry Bots in less than 5 minutes!

In this video I just save everything, when you save your own level – pick and choose the things you want to save to keep performance higher and saved games smaller.

Getting Started

Please see the Getting Started Guide for Unity Serializer available on line and as a PDF download. There is also an FAQ that you can peruse.

Why Is Unity Serializer Free?

You might be wondering what’s wrong with it, it’s free!  Why would someone give away something extremely powerful for nothing?

I believe some things should be free because everyone needs them – and if a lot of people use Unity Serializer I will benefit too from all of the testing and ideas for improvement.  I had to write this code for my game – I believe that any small amount of money I would make from selling this just isn’t worth it and would deny a whole bunch of  people the ability to build a complete game quickly. 

People should be getting on and thinking about their game play, not worrying about how to save their levels!

I do think that if I save you a bunch of time by using Unity Serializer and make some money from your game – it would be nice of you to make a donation for the upkeep of the project. 

In short:

  • It works
  • It’s supported
  • It’s free

Mike

Unity Serializer Menu & Wizard

Starting in version 0.7 there is a Wizard that can help you configure your game and a new Unity Serializer menu bar will appear after you have imported the package.  You can use the wizard to help you setup your scenesThe Wizard also contains maintenance commands to delete saved games.

There are also short cut keys to add a new script to the current object.  I strongly suggest you use the wizard for most scene configuration.

You will also be able to see colour coded information in the hierarchy view showing what script is attached to each of your game objects.

Unity Serializer References Wizard

The new page of the Unity Serializer wizard helps you to identify areas that might make saving and loading your game less robust.  Unity Serializer stores Asset references by using their type, their name and an index (so if there are three things called Take 001 – each one has an index starting from 0).  It makes your save games more robust if you keep each of the items you will refer to uniquely named.  It is not a requirement that they are unique it just improves the robustness of your saved games if they are.  The page on the wizard highlights items with matching names and lets you click on them to view them in the project window.  Items shown in red are internal to Unity and are hence quite possibly going to change more often.

NOTE: You will probably see a lot of things in this window that you never use in a reference.  You can just ignore those.

JavaScript & C# Support

You can use Unity Serializer from Javascript – so long as your javascript is not located in the Standard Assets or Plugins folders.

There is an example pause menu in the Asset Store and main package downloads here – called PauseMenu.js that will show you how to call the functions in the context of a simple javascript pause menu – activated in the demo with the P key.

iTween

iTween support is downloadable as an add on module. It enables the storage and restart of any tweens running on objects that have at least StoreInformation attached to them

In order for this to work it is necessary to add 2 lines of code to iTween. Find the IEnumerator Start() function in iTween.cs and insert the code:

if(LevelSerializer.IsDeserializing)
   return;

You will need to do this each time up upgrade iTween.

PlayMaker

I’m a big fan of PlayMaker and given that many PlayMaker users that aren’t programmers may have a problem adding Load/Save functionality I’ve developed a plug in that you can download to enable PlayMaker Finite State Machines to be saved. Once the plug in is installed you just have to attach a Store Information script to the objects that have the FSMs attached.

The plugin saves all of the local and global variables in addition to the current state of the FSM and restores all of these on load. Note that even if you only save 1 FSM, all of the global variables will of course be loaded – this might lead to strange behaviour so it is probably better to make sure you store all of your PlayMaker enabled objects.

NEW PlayMaker Actions & Demo Scene

The PlayMaker add on now has custom actions for PlayMaker to save games and checkpoints.  The package also includes an example scene that uses these actions to make a rudimentary save game menu.

Extensible

I’m adding support for as many types as possible – but I may not cover every case.  Don’t worry – you can still serialize your levels, but you might have to do some work 😉

Say you create a mesh and change the mesh of a renderer to the runtime constructed one – as of writing (version 0.84) you can’t serialize these meshes directly (it’s coming I hope!)  However you could just store enough information to recreate the mesh in some variables on a script and then write an OnDeserialized() function which takes those values are recreates whatever you need.

I will strive to add as many types as possible – but OnDeserialized() is your friend because in there you can build anything you need that hasn’t been automatically saved.

Tolerant to change

UnitySerializer does it’s best to cope with you changing the public fields and properties of your class.  Internally it tokenises the names of things and uses these to set the values back later so it can copy with quite extreme changes to structure – e.g. adding and removing large numbers of properties or fields.  It’s not so good when you change the type of a field or property to one that is not compatible (castable) from the original stored value.  If you need to change things like this I suggest you create a new property or field rather than reuse an existing name.

You can also store your files using Verbose mode – that will provide extra serialization information and does attempt to fix changing types.

To turn on Verbose mode you need to import Serialization and use UnitySerializer.Verbose = true;

In this mode you can also handle an event MapMissingType that allows you to supply a replacement type if it is semantically similar to a now defunct former type. UnitySerializer.MapMissingType += YourMissingTypeHandler;

  1. #1 by vc on June 23, 2012 - 10:01 pm

    You mention that people can donate to support this project, but I don’t see anywhere to donate on this site. Perhaps, an easy donation button

    • #2 by whydoidoit on June 23, 2012 - 11:54 pm

      Yeah – I’ve just realised that my pay pal donation button has vanished! I must have deleted it somewhere down the line… How annoying 🙂

      • #3 by vc on June 24, 2012 - 7:22 pm

        Recommend USD for donations. Your going to lose some money based on paypals conversion rate for US customers.

      • #4 by whydoidoit on June 24, 2012 - 7:45 pm

        Good point – changed it…

  2. #5 by Philip Tessier on June 25, 2012 - 5:26 am

    Mike,
    I’m relatively new to Unity and even newer to your work (though an OLD hand at software development), but I think I’m a fan! I’m currently integrating UnitySerializer into my game, with some “interesting” results so far. I’m post findings when I’m a little further along. Just wanted to let you know I’m out here.
    Phil

    • #6 by whydoidoit on June 25, 2012 - 10:53 am

      Phil

      Glad your are trying it – I would like to know what kind of problems you are having as you go along, so I can update documentation or fix bugs 🙂

      Mike

      • #7 by Philip Tessier on June 27, 2012 - 5:19 am

        Mike,
        My first attempts were a bit haphazard. I’ve slowed down a bit, and am approaching this integration in a more orderly fashion. 🙂
        I’ve installed v0.76, and have watched the Angry Bots demo video. The wizard is a great help at integrating, and seeing what’s being done! I think I’m following all the Basic Rules of the Road. I’m still having problems, however.
        For clarity, I’ll break up my report into multiple posts.

      • #8 by Philip Tessier on June 27, 2012 - 5:31 am

        First, I’m seeing a minor, though annoying, .NET issue. The Radical and Serialization scripts use default values, which seem to be only acceptable if my target framework is .NET 4.0. So, I set the target framework for the five projects in my solution to .NET 4.0.
        Unity changes them back to 3.5 every time it detects a change.
        If there is a convenient way of getting around this, I’m unaware of it, and click through those several dialogs quite frequently.

      • #9 by whydoidoit on June 27, 2012 - 5:37 am

        Ahh, are you running on Windows? I’m on a Mac – it might prove useful to see what the difference are! So if that’s a persistent problem I’ll do multiple signatures for the default parameters. It’s all of them is it?

      • #10 by Philip Tessier on June 27, 2012 - 5:42 am

        Thus far, I’m only trying to persist two of my object hierarchies: my player, and an object he can carry around.
        They look like this:
        – 3rd Person Controller
        – Main Camera
        – Camera Point Light
        – Camera Point Light
        – Overhead Camera Point Light
        – Overview Camera
        – Self
        – Body – Hand
        – Body – Finger – Index
        – Body – Finger – Middle
        – Body – Finger – Pinkie
        – Body – Finger – Ring
        – Body – Finger – Thumb
        – Slot – Back
        and
        – Key – Cube
        I’ve marked the 3rd Person Controller + Children with Store Information, and Key – Cube with Store Information. Both exist throughout the scene (being neither created nor destroyed).
        I noticed that the player’s hierarchy in Angry Bots is significantly different… Perhaps that yields a clue?

      • #11 by Philip Tessier on June 27, 2012 - 6:18 am

        Yes, I’m running on Windows XP Pro.
        All of them? I should think so. MonoDevelop counts 60 errors from “default values are not allowed.”

      • #12 by Philip Tessier on June 27, 2012 - 6:27 am

        I’m getting a dozen or so ” was null” messages on Load.
        I’ve found and enabled the “using Radical.Logging()” in the save and load functions, and was preparing to send you excerpts…
        …I noticed that the first errors are coming out of UIToolkit’s scripts. (I recently integrated that for providing a nice GUI.) They seem to be reacting badly to multiple Awake() calls.
        (I’m not sure of this; it’s late here, so I’ll have to pick up there in my next session.)
        I also noticed that, besides the complaints in the console, my scene had visible flaws (e.g., default (pink) material showing), that *varied* between different loads of the same serialization.
        I’ll investigate further… after I get some sleep! 🙂

      • #13 by Philip Tessier on June 27, 2012 - 6:29 am

        Editing above post:
        “some-unique-identifier was null”

      • #14 by Philip Tessier on June 28, 2012 - 5:17 am

        Mulling over what I’d written last night (about UIToolkit), and suspecting some sort of friction between your software and theirs, I resolved to eliminate every warning message, regardless of how insignificant it seemed. This led me to clean up my 3rdPersonController settings (with the added benefit of *that* working much better. That effort has made my serialization errors much easier to isolate.
        1. My main camera has a deserialization glitch. The skybox, originally “Sunny1 Skybox” loads to “bark_4.”
        2. I’m getting a message on load, “No Audio Listener in Scene.” I believe this is transitory.
        3. “Actor::setLinearVelocity: Actor must be (non-kinematic) dynamic!” from somewhere within RunDeferredActions. (Another paired with it, but “setAngularVelocity”.) I have not determined which objects this relates to.
        4. UIToolkit also provides a “Easing” class. Perhaps a namespace?

        The above issues exist in my “simple” test case – i.e., no PrefabIdentifiers. Other than what is noted, Save/Load works.
        I get into deeper trouble, though, when I introduce PrefabIdentifiers. Load is deleting all of my “built from prefab” objects, even though they should have been saved. (I haven’t yet checked the log in detail enough to determine whether they were actually saved.) After this, an exception is thrown:
        Missing Reference Exception: The object of type ‘GameObject’ has been destroyed but you are still trying to reference it. …
        LevelLoader+c__Iterator1.MoveNext() at … : 72

        Besides my “player” (object plus children marked with Store Information), and “Key – Cube” (marked with Store Information), I’m working with a small number of objects, and I believe I’m following the basic rules… I’ll show what I’m doing, though, in case I’m misunderstanding.
        “Sphere Vendor” – exists in scene; marked with Store Information; conditionally spawns a Sphere (possibly multiples).
        “Cube Lock 2” -exists in scene; marked with Store Information; always spawns a “Key – Cube”.
        “Sphere Lock 3” – exists in scene; marked with Store Information; always spawns a Sphere.
        “Sphere Lock 5” – exists in scene; marked with Store Information; always spawns a Sphere.
        “Key – Cube.prefab” – marked with Prefab Identifier.
        “Sphere.prefab” – marked with Prefab Identifier.

      • #15 by whydoidoit on June 28, 2012 - 3:31 pm

        Thanks for doing this Phil – this is really helping with my understanding of the documentation I need to write 🙂

        So the build error was a strange one – some versions of MonoDevelop will complain about default values, but Unity doesn’t and will quite happily build. Hopefully I’ve got most of the sorted out (mine builds everywhere without complaint) but I might have missed some still. Version 0.8 should cover this and also circumvent problems with items being loaded with the wrong texture/mesh etc.

      • #16 by Philip Tessier on June 29, 2012 - 3:19 am

        I’ve installed 0.8. Fewer errors. Errors remain in these files:
        Radical.System.Curves.cs:
        Radical.System.Loom.cs: QueueOnMainThread( time)
        Radical.System.Radical.cs: GUIArea( area), LogWarning( context), LogError( context), Instantiate( parent), SetParent( setScale) (three prototypes), FixTo( type)
        Radical.System.RadicalRoutine.cs: WaitForAnimation( time, weight), WaitForAnimation( time), WaitForAnimationWeight( weight), Run( methodName, target) (two prototypes), Execute( complete)
        Serialization.LevelSerializer.cs: SerializeLevel( urgent)
        Serialization.UnitySerializationExtensions.cs: ProvideAttributes( …allSimple)
        Serialization.UnitySerializer.cs: RegisterSerializationAssembly( assembly), ScanAllTypesForAttribute( attribute), Deserialize( instance), OldDeserializeObject( itemType, instance), Serialize( forDeserializeInto) (two prototypes), SerializeObject( first)

      • #17 by Philip Tessier on June 29, 2012 - 4:19 am

        Mike,
        I decided it would be more appropriate for me to make the changes. I have just e-mailed them to you.
        Phil

      • #18 by Philip Tessier on June 29, 2012 - 5:13 am

        Breakthrough!
        For some reason, LevelSerializer.AllPrefabs[] contains some nulls.
        I’ve modified the second loop of LevelLoader.Load() as follows:
        using( new Radical.Logging()) //Next we need to instantiate any items that are needed by the stored scene
        foreach(var sto in Data.StoredObjectNames.Where(c=>UniqueIdentifier.GetByName(c.Name) == null && !string.IsNullOrEmpty(c.ClassId) ))
        {
        var pf = LevelSerializer.AllPrefabs[sto.ClassId];
        if( pf == null)
        {
        Radical.LogNow ("Casting AllPrefabs[" + sto.ClassId + "], " + pf.ToString() + ", to GameObject... Skipping...");
        continue;
        }
        sto.GameObject = Instantiate(pf) as GameObject;
        ...

        Initial tests (with prefabs) are looking good! 😀

      • #19 by whydoidoit on June 29, 2012 - 8:15 am

        Fantastic – I expect that my test for prefabs is returning some objects that have been spirited away by Unity. Modifying the main code now.

      • #20 by Philip Tessier on July 20, 2012 - 4:41 am

        Mike,
        I’ve been away a while, but now I’m back, and ready to get my game saving!
        I’ve updated to Unity 3.5.3f3, and I’m on Unity Serializer 0.84.
        I’m still having trouble with prefabs. I’ve been “tuning” debug statements (mostly in LevelSerializer.SerializeLevel() and LevelLoader.Load()) to get a clearer idea of what’s really happening…
        Above, I reported finding nulls in AllPrefabs, and you modified the code with:

        allPrefabs = allPrefabs.Where(p=>p.Value).ToDictionary(p=>p.Key, p=>p.Value);

        Perhaps you could shed some light on this? I find it confusing on a number of levels…
        – First, if we are holding a reference to the gameObjects (in the allPrefabs dictionary), how does Unity “spirit them away”?
        – Second, they’re *prefabs*, and thus non-level-objects, so *why* would they be spirited away?
        It is the prefabs that I have marked with PrefabIdentifier that are “vanishing”. When they can’t be found, the level objects derived from them aren’t deserialized, of course.
        Thanks,
        Phil

      • #21 by whydoidoit on July 20, 2012 - 10:52 am

        Hi Phil

        So just a note: in version 0.9 you can turn on my own logging with Radical.AllowDeferredLogging = true somewhere in your code.

        Unity makes objects that it has unloaded return null – so even if you have a reference, that reference is effectively unavailable to you after the object has been destroyed by something else. In an attempt to find the prefabs I may also find instances of those prefabs which it what confuses it – those go away and the real ones stay behind. Actually you’ve just given me a head slap moment there. I’m going to adjust a couple of things and release a 0.91.

        It’s very annoying – but 0.9 has made some significant improvements with prefabs. Most notably the problem with prefabs is re-establishing the child items when a prefab is constructed. This involves being able to accurately find the correct child and give it back its unique identifier. I think I have that a lot better now.

        Best

        Mike

      • #22 by whydoidoit on July 20, 2012 - 11:04 am

        Yep – I’ve just realised why they were disappearing – thanks so much for your patience and input on this.

        The problem was I was finding the damn prefabs in the scene and using them rather than the real assets. I’ve fixed this now in v0.91 – uploading at the moment.

        Thanks again.

      • #23 by Philip Tessier on July 26, 2012 - 4:43 am

        Mike,
        I’ve loaded 0.91 and 0.93, and things are looking much better. One set of prefabs isn’t working correctly, but I think I have just realized where the problem lies…
        One of my object types (called “Bar”) (marked with StoreInformation) decorates itself with a “decal” – an instantiation of a prefab, which it parents. Because I ran into positioning problems (or some such), Bar destroys the decal’s rigidbody and collider components. I just noticed that after a Load, the decal’s have their rigidbody and collider back. I’ve just tested my theory by creating a “prefab just for decal” prefab that lacks the rigidbody and collider components, and I get the desired results when those are loaded.
        Will I need to create such prefabs for all my “decals,” or is this something you can solve?
        Thanks,
        Phil

      • #24 by whydoidoit on July 26, 2012 - 8:58 am

        I can solve that Phil – it’s definitely trying to make that happen (guess I missed something, will try to replicate).

      • #25 by whydoidoit on July 26, 2012 - 10:09 pm

        So I’ve added the ability to store the list of currently active components at serialization time – that should fix your decal problem. Available in 0.941

      • #26 by Philip Tessier on July 27, 2012 - 1:23 am

        Mike,
        0.941 is looking good! It fixed my “decal” objects, so I’m looking into the lesser evils…
        – My player’s rigidbody HAD been marked kinematic, and something called during Load was giving two errors – ala “Actor must be (non-kinematic) dynamic.” The player would position correctly, but his rotation would be off. I’ve just made it non-kinematic, and I’m happy with that.
        – My game has a “cape”, a gameObject with an interactive cloth, initially laying on its “buckle” (a scaled cube), both laying on a table (another cube). The interactive cloth has the buckle as its one attached collider. (In gameplay, the player picks up the cape and wears it.) At runtime, an empty child of the player (on his back) parents the buckle and the cape moves with it. This all seems to Serialize fine, but on Load, whether worn or still in its initial position, it flips up from its *initial* position and drifts down to the ground. All *settings* seem to be loaded correctly… perhaps this object has some private state members? (It’s not of great concern, but I thought you’d like to know.)

      • #27 by Philip Tessier on July 27, 2012 - 4:20 am

        Mike,
        There appears to be a missing “#if UNITY_EDITOR” in AdditionalData.cs (on the “using” statement).
        Phil

      • #28 by Philip Tessier on July 31, 2012 - 1:01 am

        Mike,
        0.951 looks better than ever.
        I still have one set of objects that do not appear to deserialize correctly. They are gates – gameObjects with Rigidbody and Hinge Joint components. On a trigger, I set the HingeJoint’s useMotor to true. I have these marked with StoreInformation. These are deserializing to their original closed position, regardless of whether they were open at Serialize time.

      • #29 by Philip Tessier on July 31, 2012 - 2:04 am

        (I’m wondering if Unity’s engine is rejecting the deserialization because of the Hinge Joint constraints?)

      • #30 by whydoidoit on July 31, 2012 - 1:28 pm

        Joints are a total nightmare to serialize – given the complex relationships between the participating rigidbodies. I’ve made some minor improvements in v0.965 for you to try – I hope this will help. If not then I think it will need some major thinking about for v1.1 – perhaps there’s something you could do to re-initialise in OnDeserialized()? Perhaps store if the gate is open in a bool somewhere and then fix it up yourself (if my changes don’t cut it).

      • #31 by Philip Tessier on August 1, 2012 - 3:17 am

        Mike,
        Regarding 0.965:
        Gates work beautifully! Thanks!
        – “transform.position assign attempt for ‘Main Camera’ is not valid. Input position is {7, NaN, 0.000003}.”
        – Some of my “decals” (prefabs), I change their layer at runtime. After deserialization, these have their original layer. (I can workaround this.)
        – I’m having a problem with one of my new objects… I just want to check – Dictionary should serialize, right? (subject to the usual constraints).
        Thanks,

      • #32 by Philip Tessier on August 1, 2012 - 3:49 am

        I should have included in my last post…
        My ‘Main Camera’ is attached to a ‘3rd Person Controller’, which is marked Don’t Destroy.

      • #33 by Philip Tessier on August 1, 2012 - 5:22 am

        Sure enough, the failure of Dictionary to serialize was mine – I hadn’t set a StoreInformation on that object!

    • #34 by whydoidoit on August 1, 2012 - 3:33 am

      Yes dictionaries should definitely serialize. Will check on that camera thing and look into layers. I probably presumed that they wouldn’t change at run time.

  3. #35 by Maciej Wdowiarz-Bilski on June 29, 2012 - 8:17 am

    Hi Mike, thank you for the hard work. This is intended for Load/Save functionality. May it be also used for streaming content to scene ? It’d require probably to recognize each type of Component that can be attached to GameObject and its sub-objects. Besides, what about performance – could it be used to dynamically load objects to scene ?

    Thank you,
    Maciej

    • #36 by whydoidoit on June 29, 2012 - 10:10 am

      I think it could go that way, I haven’t really performance optimised it at the moment for real time use, but I’m intending to over time. Anything that does a lot of instantiating and fiddling about with reflection is inherently slow – also to make it phone compatible I have had to dispose of the super fast methods of setting fields and properties that are available on other platforms due to the need for JIT compilation – though there are some techniques I can use to improve the performance there, it wasn’t really necessary for level loading and I haven’t got to it yet.

      • #37 by Maciej Wdowiarz-Bilski on June 29, 2012 - 10:35 am

        To make huge scene full of objects in Unity it’s virtually impossible to store everything in memory (i.e. for sanbox games such us Fallout). Thus I need streaming mechanism which will load content during player movement w/o game to stagger in this moment. Do you think, will it be able to load e.g. 1000 GameObjects in sector (region) of the game.

      • #38 by whydoidoit on June 29, 2012 - 10:48 am

        Yes it’s possible – though I would imagine you would want to spread out the load over a couple of frames. I will stick that on my list of things to add – guess we could make the loading happen as a coroutine for that circumstance.

        Are you thinking that you will stream things in and out as the player moves around the level? Sounds like a very cool additional set of functions to me… Definitely keen to work with you on that.

      • #39 by Maciej Wdowiarz-Bilski on June 29, 2012 - 11:15 am

        Yes, this is sth. that is missing in Unity for larger scenes. If you ‘ll work on that I’m sure that everybody would benefit your solution 🙂

        Regards

      • #40 by whydoidoit on June 29, 2012 - 11:11 pm

        So I’ve had a go at doing this and it was pretty successful, you can see the video here: http://www.youtube.com/watch?v=IdU2ILLbtwo let me know what you think…

      • #41 by Maciej Wdowiarz-Bilski on June 30, 2012 - 12:13 am

        Thanks for video – it seems to be working 🙂 How about loading real object used in games such as trees with mesh coliders and meshes and other components? what could be saved in real-time?

      • #42 by whydoidoit on June 30, 2012 - 12:15 am

        Well it would need trying out – but I can’t see much of a problem. Those objects I’m using are storing code generated textures and materials which is pretty heavy weight compared to instantiating a normal prefab and it’s components.

      • #43 by Maciej Wdowiarz-Bilski on June 30, 2012 - 12:30 am

        The case of prefab is reachable bacause of Resources.Load method. What is worrying me is the case, when you pull prefab on the scene, and after that you make custom changes in Hierarchy view (eg. you have complicated tree and you add script to it) w/o storing it as new prefab.. saving it that s serializing is really challenge.

      • #44 by whydoidoit on June 30, 2012 - 6:36 am

        Yeah using Unity Serializer you will have no problems with that unless you procedurally change the mesh (for now that isn’t storable). You can change anything else you like and it will play it on to the original prefab.

      • #45 by Maciej Wdowiarz-Bilski on June 30, 2012 - 3:54 pm

        Mike, does it mean that your serializer could handle any object on scene, which isn’t procedurally modified ? That’s v. good news because as part of team I’m developing mmorpg game utilizing mechanism which will load/unload any object on one, v. large scene such as house/tree/trap/any 🙂

  4. #46 by Ced on June 29, 2012 - 10:05 am

    Hi Mike!
    I’m currently testing your serializer into my unity’s project. It’s a very useful tool, especially with the integration of the wizard.
    I succeeded in saving the position of every object that I want. But i’m also looking for a way to save the materials applied on my objects. (User can change material upon objects)
    Do you think it can be done? How?
    Thanks!

    • #47 by whydoidoit on June 29, 2012 - 10:07 am

      Starting from version 0.74 (and more stable in 0.8) you can store Material references plus Textures etc. let me know if it isn’t working for you and I will fix it 🙂

    • #48 by whydoidoit on June 29, 2012 - 10:13 am

      Actually I bet it won’t store materials that you make up at runtime yet – hmmm, is that what you are doing? It’s possible I could make it do that too, now I have the correct code for storing the things that material references.

    • #49 by whydoidoit on June 29, 2012 - 10:23 am

      And one final point on this. You can always store variables that describe the way to make something like a material and then write an OnDeserialized() method to recreate you material at level load time. I do this for lots of things that are hard to save.

    • #50 by whydoidoit on June 29, 2012 - 8:01 pm

      I have added full material and texture support, both for references and from script generated items.

  5. #51 by Ced on July 2, 2012 - 9:25 am

    Thanks a lot Mike! It works great!
    I tested it this morning, there’s only one thing, it doesn’t seems to work with “substance” materials.
    Or maybe I made a mistake. It could be an idea for a futur update.

    Great work!

    • #52 by whydoidoit on July 2, 2012 - 9:30 am

      Oh really, damn. I will try it out with some Allegorithmic substances and see if I can get it working.

  6. #53 by Matt on July 4, 2012 - 12:58 am

    Does your software support saving an object of type XmlDocument? I recieve a NullReferenceException when I try to save a script which has an XmlDocument variable in it.

    • #54 by Matt on July 4, 2012 - 1:16 am

      I tested it and the saving does not handle variables of type XmlDocument. It also does not handle variables of type List.

      • #55 by Matt on July 4, 2012 - 1:17 am

        For some reason I cannot edit my last post. It throws a NullReferenceException when you try to save a List of variables of type Texture. It appears to be working for other types of Lists however

      • #56 by whydoidoit on July 4, 2012 - 3:10 am

        First posts on here are moderated – after that you should be fine to keep posting without waiting for me 🙂 I will check out the list of Textures – sounds like a bug that should be easy enough to nail.

      • #57 by whydoidoit on July 4, 2012 - 3:09 am

        Hi Matt – I’m not sure about storing an XmlDocument – I would guess not as that is an internal type with a complicated set of constructors.

      • #58 by whydoidoit on July 4, 2012 - 3:11 am

        It definitely handles normal lists. Will check on lists of references.

      • #59 by whydoidoit on July 4, 2012 - 3:32 am

        I can serialize a List of Textures no problem with version 0.84 – what problem are you having?

      • #60 by Matt on July 5, 2012 - 9:42 pm

        I was getting a null reference exception when I tried to serialize a:
        List buttons = new List();

        This is not a problem however as I really dont need to save this so I just marked it to not get saved.

        What I am trying to do now is save a couple classes that I have which do not inherit from MonoBehaviour. Neither of the classes have default constructors and I require some variables inside the classes to be saved.

        Should I look at SilverlightSerializer for that information or is that something different?

        An example for what I am looking to save is:

        MonthEntity – Class I wrote which stores information about a month including an array of Days (another class I have)
        Day – Class with various information on a day.

        Thanks

      • #61 by Matt on July 5, 2012 - 9:46 pm

        For some reason it removes text contained inside a less than and greater than sign so my above code does not show up right

      • #62 by whydoidoit on July 6, 2012 - 1:03 am

        Yes it uses the same method of storing non-default constructed classes – the serializer needs it to construct a class instance – will also move the docs across later – but for now you should be able to use the SS doc. CreateType is the event you are after.

      • #63 by whydoidoit on July 20, 2012 - 10:55 pm

        I wrote it initially because I needed it on the iPhone for auto saving when the game goes into the background – so it was working fine. How strange. Does the data in PlayerPrefs look like it’s right?

    • #64 by Matt on July 6, 2012 - 12:58 am

      I am repeatedly finding myself running into the error:

      Serialization error: System.NullReferenceException: Object reference not set to an instance of an object

      It happens when I attempt to load a saved game. I am finding it hard to debug the exact cause of this error. The only approach I have found is to slowly remove things I am saving until I find the problematic item.

      Is there a better way to find the cause I am not finding the debug log very helpful?

      • #65 by whydoidoit on July 6, 2012 - 1:04 am

        Can you not connect the MonoDevelop debugger and set it to break on NullReference exceptions?

      • #66 by whydoidoit on July 6, 2012 - 7:07 am

        Also there is much more advanced debugging information available – but I need to make it easier to turn on in the next version – I can help you with that in 0.84 if you would like to use it. But MonoDevelop, attach to process, set exception NullReference on is the easiest way to go in your case I think.

    • #67 by Matt on July 12, 2012 - 12:25 am

      I am attempting to set up my save system so when they save the game it will override any previous saved games and make the new save the one to be used if the game is resumed later on. Is the best way to do this to go through any previous saved games and delete them then save the new game?

      Also I am trying to loop through all the LevelSerializer.SavedGames but the type SaveEntry is invalid. Is there something I need to import for this?

      • #68 by whydoidoit on July 12, 2012 - 7:37 am

        You need to use LevelSerializer.SaveEntry.

        You might be better off using Checkpoint() and Resume() if you only want one saved game, otherwise deleting those entries is the right way to go and I am improving that for the upcoming 0.9 release.

        You can also just stored a string anywhere you like using LevelSerializer.SerializeLevel and LevelSerializer.LoadSavedLevel.

    • #69 by Matt on July 18, 2012 - 9:42 pm

      Does your serializer attempt to save C# properties? I was stuck for a good while on a null reference exception that I could not figure out. I was able to fix the issue when I put the [DoNotSerialize] tag over one of my properties. I was under the impression that these were treated as functions and not variables.

      • #70 by Matt on July 19, 2012 - 1:27 am

        Also I have a prefab game object which contains several children objects. I instantiate this at runtime. I have the prefab marked with the prefab identifier however it does not properly save the child objects. Applying the store information for the GameObject + children does not work on the prefab. When I have the objects in the scene I can apply the Save Information for children and it works fine just not with the prefabs I instantiate. Is there a way around this? Maybe at runtime setting those objects + children to be saved via code?

      • #71 by whydoidoit on July 19, 2012 - 11:13 am

        Yes the serializer serializes all public properties and fields by default – it will never serialize private properties. I could add flags to toggle that behaviour – for my own use I nearly always serialize properties because I want the effect of setting it to be persisted.

      • #72 by whydoidoit on July 19, 2012 - 11:15 am

        So the prefab should have a PrefabIdentifier and the children should all have StoreInformation set on them. In versions before the (at the time of writing) unreleased 0.9 the prefab identifier stores the index in the children array of StoreInformation to assign the ID back correctly – this can sometimes lead to problems if you have deleted a bit of the prefab!

    • #73 by Matt on July 20, 2012 - 10:04 pm

      Does the Checkpoint() and Resume() functions work for the Ipad. Currently I am having trouble getting it to resume my game saved via Checkpoint. It appears to be saving the game with Checkpoint() but when I call Resume() nothing seems to happen and no errors are thrown. I have debugged it to ensure that Resume() is called.

      • #74 by Matt on July 20, 2012 - 11:00 pm

        After further inspection it appears the Checkpoint() is not actually saving the game and throws an error when debugging with XCode

      • #75 by Matt on July 20, 2012 - 11:17 pm

        I have tried the following but each appears to crash my game on the Ipad:

        LevelSerializer.SaveGame(“GameSave1”);
        LevelSerializer.Checkpoint();
        PlayerPrefs.SetString(“_PAUSE_GAME_”, LevelSerializer.SerializeLevel());

      • #76 by whydoidoit on July 20, 2012 - 11:18 pm

        What error is XCode giving you? A null ref?

      • #77 by Matt on July 21, 2012 - 12:07 am

        Yes I believe it is a null ref. I am still pretty new to using xcode so I havent figured out exactly how to debug and use breakpoints properly with it. It tells me the following:

        Thread 1: EXC_BAD_ACCESS (code = 1, address=0x0)

      • #78 by whydoidoit on July 21, 2012 - 12:08 am

        Ok that’s a null reference – can you see the stack trace on the left hand side? Can you see what routine it came from?

        Strange if it works in the editor.

      • #79 by Matt on July 21, 2012 - 12:36 am

        Thread 1, Queue : com.apple.main-thread
        #0 0x000d516c in Serialization_GetSetGeneric__GetSetGenericc__AnonStorey7__m__24_object at /Users/admin/Desktop/MattsTestBuild/Libraries/Assembly-CSharp-firstpass.dll.s:32534
        #1 0x000d5984 in Serialization_GetWritableAttributes__GetPropertiesc__AnonStorey9__m__29_Serialization_GetSet at /Users/admin/Desktop/MattsTestBuild/Libraries/Assembly-CSharp-firstpass.dll.s:32798
        #2 0x0025e56c in System_Linq_Enumerable__CreateSelectIteratorc__Iterator10_2_MoveNext at /Users/admin/Desktop/MattsTestBuild/Libraries/System.Core.dll.s:2959
        #3 0x0025f0ec in System_Linq_Enumerable__CreateWhereIteratorc__Iterator1D_1_MoveNext at /Users/admin/Desktop/MattsTestBuild/Libraries/System.Core.dll.s:3224
        #4 0x0025e5c0 in System_Linq_Enumerable__CreateSelectIteratorc__Iterator10_2_MoveNext at /Users/admin/Desktop/MattsTestBuild/Libraries/System.Core.dll.s:2963
        #5 0x0047a46c in System_Collections_Generic_List_1_AddEnumerable_System_Collections_Generic_IEnumerable_1_T at /Users/admin/Desktop/MattsTestBuild/Libraries/mscorlib.dll.s:28694
        #6 0x00479970 in System_Collections_Generic_List_1__ctor_System_Collections_Generic_IEnumerable_1_T at /Users/admin/Desktop/MattsTestBuild/Libraries/mscorlib.dll.s:28267
        #7 0x0025b660 in System_Linq_Enumerable_ToArray_TSource_System_Collections_Generic_IEnumerable_1_TSource at /Users/admin/Desktop/MattsTestBuild/Libraries/System.Core.dll.s:1812
        #8 0x000af3a4 in Serialization_GetWritableAttributes_GetProperties_object at /Users/admin/Desktop/MattsTestBuild/Libraries/Assembly-CSharp-firstpass.dll.s:14096
        #9 0x000ce3b0 in Serialization_UnitySerializer_WriteProperties_System_Type_object_Serialization_IStorage at /Users/admin/Desktop/MattsTestBuild/Libraries/Assembly-CSharp-firstpass.dll.s:29458
        #10 0x000cea44 in Serialization_UnitySerializer_SerializeObjectAndProperties_object_System_Type_Serialization_IStorage at /Users/admin/Desktop/MattsTestBuild/Libraries/Assembly-CSharp-firstpass.dll.s:29614
        #11 0x000cd444 in Serialization_UnitySerializer_SerializeObject_Serialization_Entry_Serialization_IStorage_bool at /Users/admin/Desktop/MattsTestBuild/Libraries/Assembly-CSharp-firstpass.dll.s:29123
        #12 0x000cbb5c in Serialization_UnitySerializer_Serialize_object_System_IO_Stream_bool at /Users/admin/Desktop/MattsTestBuild/Libraries/Assembly-CSharp-firstpass.dll.s:28581
        #13 0x000cbdc0 in Serialization_UnitySerializer_SerializeForDeserializeInto_object at /Users/admin/Desktop/MattsTestBuild/Libraries/Assembly-CSharp-firstpass.dll.s:28659
        #14 0x000b5a88 in SuspendLevelSerialization__ctor at /Users/admin/Desktop/MattsTestBuild/Libraries/Assembly-CSharp-firstpass.dll.s:17678

      • #80 by whydoidoit on July 21, 2012 - 12:56 am

        Hmmm, that looks like it’s trying to save a game object that has been destroyed.

      • #81 by Matt on July 21, 2012 - 12:58 am

        Any reason it would work fine in the Unity editor but not on the Ipad?

      • #82 by Matt on July 21, 2012 - 1:15 am

        A couple things I was wondering about:

        If I put a [DoNotSerialize] tag over a class will it not save any of the member variables for that class?

        Also if I have a class object that is marked to save but that class object is marked as [DoNotSerialize] will it save the variables in that class?

      • #83 by whydoidoit on July 26, 2012 - 10:08 pm

        [DoNotSerialize] can be put on a class and it will not be stored, or a property or field and that single item will not be stored. A behaviour can have a [DontStore] attribute to stop it being considered. If the class is marked DoNotSerialize then it will not be stored even if the variable can be.

      • #84 by Matt on July 26, 2012 - 11:01 pm

        I am running into issues when I try to save items that are

    • #85 by Matt on July 26, 2012 - 11:07 pm

      I am running into issues when I attempt to save prefab objects that are instantiated at run time. Some of the objects exist in the game from the start and when I instantiate more of those objects and save them they work fine. However some of the objects do not exist in the game prior to starting and when I instantiate those and save them they turn up as null and do not load. These objects are instantiated at multiple times during the game so the “Capture all objects” button will not capture them being instantiated. The objects consist of one parent object with multiple children objects. I have the parent object marked with a prefab identifier and all the children objects are marked with save information.

      • #86 by whydoidoit on July 26, 2012 - 11:12 pm

        You don’t need to capture any objects that are not a part of the scene. It would appear that what you are doing is correct (the example scene just spawns prefabs all the time) so I’m concerned something else isn’t happening. What appears to be null? A reference in the Log? Is there anything special about these.

      • #87 by Matt on July 26, 2012 - 11:30 pm

        Unfortunately I do not get a log. I am in a weird position. When I run the game through xcode so I can debug I get the error I posted above. This error freezes the game when I attempt to save. It will do this when I try to save anything in the scene. I removed every saved item except one game object and attempted to save and it still froze. However If I build the app and run it on the ipad it does not freeze. However the prefab items I am trying to save are blank. When I run on the Mac I am able to save the items but only if I have a copy of the prefab already in the scene at the start. If that prefab does not exist in the game at the start it will not save and shows up with the warning that the object was attempted to be loaded but was null. This happens on the Mac and Ipad. I cannot get any prefab items to save/load properly on the ipad even if I can get it working on the Mac

      • #88 by Matt on July 26, 2012 - 11:43 pm

        To test it I made a simple prefab which was just a cube. I instantiated the cube then saved the game then loaded the game. The cube did not save. It has the prefab identifier on it. Going to try this within a blank game. I get the messages:

        Problem creating 9446839b-6f17-45ee-ac10-798ecd2eb0aa System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
        at System.Collections.Generic.Dictionary`2[System.String,UnityEngine.GameObject].get_Item (System.String key) [0x00000] in :0
        at LevelLoader+c__Iterator1.MoveNext () [0x001f4] in /Users/admin/MSUFCUSpartanVilla2/Assets/Plugins/whydoidoit.com/Serialization/LevelLoader.cs:104
        UnityEngine.Debug:LogWarning(Object)
        Radical:LogWarning(String, Object) (at Assets/Plugins/whydoidoit.com/Radical/System/Radical.cs:697)
        Radical:LogWarning(String) (at Assets/Plugins/whydoidoit.com/Radical/System/Radical.cs:685)
        c__Iterator1:MoveNext() (at Assets/Plugins/whydoidoit.com/Serialization/LevelLoader.cs:142)

        Also:

        Could not find 9446839b-6f17-45ee-ac10-798ecd2eb0aa
        UnityEngine.Debug:Log(Object)
        Radical:LogNow(String, Object[]) (at Assets/Plugins/whydoidoit.com/Radical/System/Radical.cs:680)
        c__Iterator1:MoveNext() (at Assets/Plugins/whydoidoit.com/Serialization/LevelLoader.cs:152)

        Also:

        9446839b-6f17-45ee-ac10-798ecd2eb0aa was null
        UnityEngine.Debug:LogWarning(Object)
        Radical:LogWarning(String, Object) (at Assets/Plugins/whydoidoit.com/Radical/System/Radical.cs:697)
        Radical:LogWarning(String) (at Assets/Plugins/whydoidoit.com/Radical/System/Radical.cs:685)
        c__Iterator1:MoveNext() (at Assets/Plugins/whydoidoit.com/Serialization/LevelLoader.cs:192)

      • #89 by Matt on July 26, 2012 - 11:52 pm

        Tested in a blank scene and and seeing the same problem. I am saving via:

        LevelSerializer.Checkpoint();

        I am loading via:

        LevelSerializer.Resume();

        I will try one of your example projects now

      • #90 by Matt on July 27, 2012 - 12:00 am

        I also noticed that a GameObject name New Game Object does appear in the scene briefly with the Level Loader script on it. It then disappears quickly.

      • #91 by whydoidoit on July 27, 2012 - 8:07 am

        You should be able to access the Xcode console view when you are debugging on the device. I’m happy to screen share on Skype to get this working – in the high level, everything you are trying works, so it must be something in the detail.

      • #92 by whydoidoit on July 27, 2012 - 8:15 am

        On the “Problem creating xxxx-xxxx-xxxx-xxxx” error line there should be the exception listed next (you might have to expand the console window to see it – I could do with knowing the error and stack trace for that line. I’m guessing that it couldn’t find the prefab and therefore the value is null and the instantiate fails – why it couldn’t find it is beyond me. I could do with either seeing the project (directly, screen cast) or perhaps a series of screen shots of the setup with the inspector showing.

  7. #93 by Brian Lee on July 5, 2012 - 2:50 am

    Hi, um. I’m encountering some issues. My game runs fine, but when I try to build I get the errors

    UnitySerializationExtensions.cs(123,20): The type or namespace ‘MovieTexture’ could not be found.
    UnitySerializationExtensions.cs(123,2): The best overloaded method match for ‘Serialization.SerializerAttribute.SerializerAttribute(System.Type)’ has some invalid arguments.
    UnitySerializationExtensions.cs(123,2): Argument #1 cannot convert ‘object’ expression to type ‘System.Type’

    I’m using the latest version of Unity 3 and the Unity Serializer version available from the Asset Store.

    Thanks!

    • #94 by whydoidoit on July 5, 2012 - 3:28 am

      Hi Brian

      Try using Version 0.84 – I removed specific references to MovieTexture as it isn’t available on iPhone/Droid – the changes should mean that no longer shows as an error but will still store Movies etc on platforms which support it.

      Best

      Mike

    • #95 by whydoidoit on July 5, 2012 - 4:09 am

      I think due to all the changes on UDN the update on Asset Store to 0.84 has been delayed.

      • #96 by Brian Lee on July 5, 2012 - 4:42 am

        Hi Mike,

        First of all, thanks for the prompt reply. It’s really appreciated. I’ve used the .84 version but now I have another build error. Any thoughts? Thank you very much!

        UnityException: Failed assemblies stripper: /Applications/Unity/Unity.app/Contents/Frameworks/Mono/bin/mono “/Applications/Unity/Unity.app/Contents/Frameworks/Tools/UnusedBytecodeStripper/UnusedBytecodeStripper.exe” -l none -c link -a “Assembly-CSharp-firstpass.dll” -a “Assembly-CSharp.dll” -a “Assembly-UnityScript-firstpass.dll” -a “Assembly-UnityScript.dll” -out output -x “/Applications/Unity/Unity.app/Contents/Frameworks/Tools/UnusedBytecodeStripper/link.xml” -d “Temp/StagingArea/Data/Managed” -x “tmplink.xml” current dir : Temp/StagingArea/Data/Managed
        result file exists: False
        stdout:
        stderr: Unhandled Exception: Mono.Linker.ResolutionException: Can not resolve reference: System.Type System.Type::MakeGenericType(System.Type[]) at Mono.Linker.Steps.MarkStep.MarkMethod

      • #97 by Brian Lee on July 5, 2012 - 4:56 am

        Mike,

        I got around the exception by specifying ByteCode stripping level. Thanks again!

      • #98 by whydoidoit on July 5, 2012 - 7:18 am

        Hmm – but there shouldn’t be a reference to MakeGenericType any more – have you accidentally got an old version and a new version in the same install – I had to change the file structure a few time before settling on the current one (which shouldn’t change again).

      • #99 by Brian Lee on July 5, 2012 - 7:30 am

        I installed the .84 version over the .8 version, but before I did so, I was certain to have deleted the whydoidoit.com folder.

      • #100 by whydoidoit on July 5, 2012 - 7:32 am

        Ok – I will check it out – maybe something is still including it for some reason. It certainly doesn’t use it directly – but perhaps one of the workarounds causes it to be referenced. I wish I could use it: would be 2x faster – but not compatible with the AOT compilation for IOS.

  8. #101 by Kasper Rodil on July 5, 2012 - 7:45 pm

    Hey mate,
    Looks very interesting.
    I am currently knee deep in making a little app on a Droid Tablet where the user spawns objects from a gui and moves them around in order to create a little town.
    Will this work on a build version, since I can only see you running it from the editor… I fear your answer? 🙂
    Basically I only need a way of serializing objects(prefab names) and their positions (x,y,z world space) for a later reload. The reason for doing it is I wanna compare how different users recreate something they all know, but how much their representations vary from each other… hope it makes sense.at least some background.
    All the best,
    Krodil

    • #102 by whydoidoit on July 6, 2012 - 1:06 am

      Hi 🙂 Yes it will work on a Droid at runtime – you will need 0.84 because the build for mobiles was broken in the 0.72-0.82 releases. The Serializer uses a slower method of serialization than would be possible on desktop environments to ensure that it works fine in Ahead Of Time compilation scenarios…

  9. #103 by ic on July 6, 2012 - 1:45 pm

    Hi Mike! Nice office 😉

    You mention that the data is ultimately stored in PlayerPrefs, which makes it accessible on iOS and Android without some external file system plugin…

    But, how are you storing binary data in PlayerPrefs…

    and also, is it possible to access this highly compressed string (i.e., to save it to the “cloud” for download by another player running a different instance, for read on a non-local system)?

    • #104 by whydoidoit on July 6, 2012 - 2:47 pm

      The compressed binary representation I make is converted to a Base64 encoded string and back again (using Convert.ToBase64String(byteArray))

      Yes you can store data in the cloud – you can create and use a string using LevelSerializer.LoadSavedLevel and LevelSerializer.SerializeLevel.

  10. #105 by Dustin on July 17, 2012 - 8:05 pm

    I’m having an issue with prefab identifiers. They drop references to child objects within them, or sometimes randomly reference another instance’s child instead. So when I press load I get endless null errors. Active Hotween scripts also break it but that’s probably just not compatible.

    • #106 by whydoidoit on July 18, 2012 - 3:31 pm

      I am working on improving the way that prefabs within prefabs work for 0.9 – that is a sticky issue and I think I have a much better solution now. Would be great if you could try it out. I haven’t tried Active Hotween – most of these things are easy to support – it’s just a matter of knowing about them and fiddling until it work :S

      • #107 by Dustin on July 18, 2012 - 4:56 pm

        Cool! Thanks for the reply. Looking forward to 0.9.

      • #108 by Dustin on July 23, 2012 - 11:27 pm

        Trying 0.92, same issue arises. All enemy prefabs have references to objects on the first enemy prefab in the hierarchy.

      • #109 by whydoidoit on July 24, 2012 - 4:51 pm

        Hmmm, I’m having a hard time replicating that – let me see if I can work it out. Is this component references rather than game object references?

      • #110 by whydoidoit on July 24, 2012 - 4:54 pm

        Is there something allocating these references in your code that is perhaps still running even when saving and reloading the game? Normally you would bypass reference setting when loading by checking for LevelSerializer.IsDeserializing and letting the persistence system handle the reassignment. I can reference scripts in mutiple places and it works – so perhaps a more detailed description of the problem would help me build a similar test case.

      • #111 by Dustin on July 24, 2012 - 7:15 pm

        They’re game objects and the references are set in the editor. Maybe the issue is with self-referencing prefabs?

      • #112 by whydoidoit on July 24, 2012 - 7:30 pm

        Well in 0.93 I made a couple of mods and have prefab children referring to siblings and the parent and that is working. It might have been the mods I made that fixed it – not sure.

      • #113 by Dustin on July 29, 2012 - 2:21 am

        Not sure if this screenshot is any more illuminating but this is what’s happening. These are preexisting prefabs.

      • #114 by whydoidoit on July 29, 2012 - 8:12 am

        Yes that makes more sense. You also need scripts attached to the children of the root prefab object (to save space) the other items in your picture will need StoreInformation or Uniqueidentifier adding.

      • #115 by whydoidoit on July 29, 2012 - 8:13 am

        Yes that makes more sense. You also need scripts attached to the children of the root prefab object (to save space) the other items in your picture will need StoreInformation or Uniqueidentifier adding.

        I’m about to update the docs to make this much more clear!

      • #116 by Dustin on August 1, 2012 - 12:59 am

        Thanks very much, that fixed it. I have a question about serializing co-routines however: A simple example is my locked door routine which plays the lock breaking animation and after a delay, destroys the lock object. When loading a save in the middle of unlocking, that co-routine seems to not be running. Are co-routines not supported and just something needed to be worked around?

      • #117 by whydoidoit on August 1, 2012 - 1:02 am

        You have to start them using my own methods – see the new Getting Started Guide for instructions

  11. #118 by LaRae Novell on July 19, 2012 - 2:48 pm

    I just want to give you a huge thank you for this. I’m not a programmer, so when I started reading about what would be required in order to script a save file, I hoped maybe someone offered a solution at a reasonable price. When I saw someone charging $99 for something that seems so integral, I was floored. The fact that you’re doing this for free is incredibly awesome and kind of you. Again, thank you so much!

  12. #119 by Grant Morgan on July 26, 2012 - 1:15 am

    Thanks this looks great. Although I am having problem compiling for webplayer. I get this primary error in my unity console.
    “Assets/Plugins/whydoidoit.com/Serialization/OnlyInRangeManager.cs(206,30): error CS0117: `System.IO.File’ does not contain a definition for `ReadAllBytes’ ”
    Also few more errors but I think they are caused by the first error.
    I created an new project and imported “JustSerialization_v0.93.unitypackage” and I still get the error. It is ok for all other build settings I tested (stand alone, iOS, Android and flash ). Is this something something corrupted in my my install or are others experiencing this?
    (OS X 10.7.4, unity3d 3.5.3f3)

    Cheers,
    Grant

    • #120 by whydoidoit on July 26, 2012 - 8:59 am

      Ah yeah – I don’t know what’s going on with that – something I missed in the docs somewhere. ReadAllBytes seems to be working only intermittently – I will replace it with something else. You can just delete that file for now if you aren’t using the “save me when I’m out of range” features.

    • #121 by whydoidoit on July 26, 2012 - 10:06 pm

      Fixed the read all bytes problem in 0.941.

  13. #122 by Rmatey on July 31, 2012 - 5:20 pm

    Awesome

  1. 100% Free Unity Serialization – Load & Save game « Mike Talbot's Blog
  2. Free Unity Serialization (Load and Save Game) full demonstration project available « Mike Talbot's Blog
  3. PlayMaker support added to Unity Serializer « Mike Talbot's Blog
  4. Major new release of Unity Serializer Beta (v0.4) « Mike Talbot's Blog
  5. Unity Serializer – Save Game for Angry Bots « Mike Talbot's Blog
  6. Unity Serializer Version 0.5 available « Mike Talbot's Blog
  7. Unity Serializer Version 0.5 available « Mike Talbot's Blog
  8. Unity Serializer version 0.6 released – now with iTween Support « Mike Talbot's Blog
  9. New Demo of Unity Serializer – Add Save Game to Angry Bots in < 10 minutes! « Mike Talbot's Blog
  10. New version of Unity Serializer v0.7 « Mike Talbot's Blog
  11. UnitySerializer v0.74 released – automatic NavMeshAgent support and Texture2D references added « Mike Talbot's Blog
  12. Unity Serializer v0.84 – Store script created materials and textures – compressed files « Mike Talbot's Blog
  13. Unity Serializer PlayMaker extension now has custom actions « Mike Talbot's Blog

Leave a comment