Custom saver
Posted: Mon Feb 18, 2019 7:31 pm
I'm trying to code my own custom saver.
It's a very easy one getting the enum state from a component <ChestInteractable> on the same gameobject on the saver, where we can find a variable with the actual state of the chest (bloqued, closed, open)
But i'm getting in troubles as I can't access to my class as the editor doesn't recognize my classes.
Could you help me a bit how do I start? And how do I write to serialize a easy enum variable?
Thanks.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace PixelCrushers
{
public class SaverChest : Saver
{
public enum EstadoChest { Bloqueado, Cerrado, Abierto };
public EstadoChest EstadoChestActual;
public override string RecordData()
{
/// This method should return a string that represents the data you want to save.
/// You can use SaveSystem.Serialize() to serialize a serializable object to a
/// string. This will use the serializer component on the Save System GameObject,
/// which defaults to JSON serialization.
///
gameObject.GetComponent<ChestInteractable>().estadoChest //Doesn't find the class
return string.Empty;
}
public override void ApplyData(string data)
It's a very easy one getting the enum state from a component <ChestInteractable> on the same gameobject on the saver, where we can find a variable with the actual state of the chest (bloqued, closed, open)
But i'm getting in troubles as I can't access to my class as the editor doesn't recognize my classes.
Could you help me a bit how do I start? And how do I write to serialize a easy enum variable?
Thanks.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace PixelCrushers
{
public class SaverChest : Saver
{
public enum EstadoChest { Bloqueado, Cerrado, Abierto };
public EstadoChest EstadoChestActual;
public override string RecordData()
{
/// This method should return a string that represents the data you want to save.
/// You can use SaveSystem.Serialize() to serialize a serializable object to a
/// string. This will use the serializer component on the Save System GameObject,
/// which defaults to JSON serialization.
///
gameObject.GetComponent<ChestInteractable>().estadoChest //Doesn't find the class
return string.Empty;
}
public override void ApplyData(string data)