Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am having some trouble serializing/deserializing in a little game I am doing to teach myself monogame.

Basically, I am using the gamestatemnanagement resources common to monogame (screen manager etc). Then I am serializing my screen manager component and all associated screens in the OnDeactivated method:

 protected override void OnDeactivated(Object sender, EventArgs args)
    {
        foreach (GameplayScreen screen in mScreenManager.GetScreens())
        {
            DataManager.SaveData(screen.Level.LevelData);
        }
        mScreenManager.SerializeState();
    }

The Save data bit is to do with something else.

Then I then override OnActivated to de serialize

    protected override void OnActivated(Object sender, EventArgs args)
    {
        //System.Diagnostics.Debug.WriteLine("here activating");
        mScreenManager.DeserializeState();
    } 

However, when this runs it just loads a blank screen - it goes into the game initialize and the game draw method, but doesnt go down into the screens initialize or draw methods.

I have no idea why this might be - any help would be greatly appreciated. I am not the only one who has encountered this - I found this post also - https://monogame.codeplex.com/discussions/391117

share|improve this question
add comment

1 Answer

I am willing to bet that you need to mark your model's tags (the ones you want anyway) with the "Serializable" Attribute tag.

http://msdn.microsoft.com/en-us/library/system.serializableattribute(v=vs.110).aspx

I can't find anything to prove otherwise, but I am very doubtful that DeserializeState has no arguments, you likely need to point to what is being deserialized.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.