Save and Load plus a few other stuff

I am having a little trouble with some stuff at Unity.
First of all, what is the best way to save and load a PC Plataform game?

If it’s XML, can someone show me a good and simple example? Because the one I made I got nullreferences at them. If needed, I’ll post the code down.

Next issue: When loaded, how to set those values to the right places? Put them through the Start from the codes? Isn’t there an easier way? Like a Data Bind, or something?

I am getting null in these:

`currentHealth = InfoHolder.Instance.CurrentHP;`

And on the SaveData below, that is the InfoHolder.

> using UnityEngine; using
> System.Collections;
> 
> public class InfoHolder :
> MonoBehaviour {
>     public static InfoHolder Instance;
> 
> 	//Preencher com os mesmos valores que
> vão ser usados no SaveData. Quando o
> jogo for carregado, serão passados
> para cá os valores e vice-versa quando
> salvo.
>     //Procure e preencha daqui os valores.
> 
>     public int CurrentHP = 100;
>     public int MaxHP = 100;
>     public int CurrentMP = 100;
>     public int MaxMP = 100;
>     public int Fruits = 0;
>     public bool LevelChocLabEnter = false;
> 
>     public void Bezier()
>     {
>         switch (Application.loadedLevel)
>         {
>             case 1:
>                 LevelChocLabEnter = true;
>                 break;
>         }
>     }
> 
>     public void CallSave()
>     {
>         SaveData.Instance.CurrentHP = CurrentHP;
>         SaveData.Instance.MaxHP = MaxHP;
>         SaveData.Instance.CurrentMP = CurrentMP;
>         SaveData.Instance.MaxMP = MaxMP;
>         SaveData.Instance.Fruits = Fruits;
>         SaveData.Instance.levelReached = Application.loadedLevel; //Essa variável pega o último level em que o
> personagem pisou.
>         SaveData.Instance.LevelChocLabEnter =
> LevelChocLabEnter;
> 
>         SaveLoad.Save();
>     } }

Thanks in advance,
Pedro Loures.

Great community made XML parser :

http://www.unifycommunity.com/wiki/index.php?title=Save_and_Load_from_XML

a good class structure for the data is the best way of storing the data in the XML

Hope this helps - C

I’ve seen that, and that did help, what I wanted was to understand where can I set what else do I want to save. Since that seems to save only the player position, and I wanna save lots of variables.

And for some reason, I dunno why, the InfoHolder.Instance.Bezier(), for example, is returning as null, as I can’t do it like that, even though I did it just like it before with my Third Person Control.

I know how to use the serialization, but ok, I made it work. I couldn’t use instance because they weren’t in the same object. I then had to made the methods public and static. With that I could acess them. Saving and Loading was easier to understand once that worked out.

Thanks for the help, Caius1!