Hello guys,
I was wondering if any good soul would be able to convert this action in a playmaker script for us to save our variables in unity.
I saw this tutorial here
https://unity3d.com/pt/learn/tutorials/modules/beginner/live-training-archive/persistence-data-saving-loadingThen watched it pausing and manage to copy the commands, so maybe its easier for someone to make it playmaker friendly.
They say that its a lot safer then playerprefs, so I think we should use it...
I think someone with little coding experience could turn it into playmaker with fields that we can put our own variables.
Someone can help?
Thanks a lot.
Doug.
update: I don't even know how to save a script in monodevelop, I think i've meesed it up, so I'm copying the commands here:
using System;
using UnityEngine;
using System.Collections;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
public class GameControl : MonoBehaviour {
public static GameControl control;
public float health;
public float experience;
void Awake () {
}
public void Save()
{
BinaryFormatter bf = new BinaryFormatter();
FileStream file = File.Create(Application.persistentDataPath + "/playerInfo.dat");
PlayerData data = new PlayerData ();
data.health = health;
data.experience = experience;
bf.Serialize (file, data);
file.Close ();
}
public void Load()
{
if(File.Exists(Application.persistentDataPath + "/playerInfo.dat");
{
BinaryFormatter bf = new BinaryFormatter();
FileStream file = File.Open(Application.persistentDataPath + "/playerInfo.dat", FileMode.Open);
PlayerData data = (PlayerData)bf.Deserialize(file);
health = data.health;
experience = data.experience;
}
}
[Serializable]
class PlayerData
{
public float health;
public float experience;
}