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.