public override object Read(ES2Reader reader)
{
MyScriptableObject data = new MyScriptableObject ();
// Add your reader.Read calls here and return your object.
data.isEnabled = reader.Read<System.Boolean>();
return data;
}
As ScriptableObject can only be created using ScriptableObject.CreateInstance<T>(), you would need to modify the Read method in the ES2Type file to this:
public override object Read(ES2Reader reader)
{
MyScriptableObject data = ScriptableObject.CreateInstance<MyScriptableObject>();
// Add your reader.Read calls here and return your object.
data.isEnabled = reader.Read<System.Boolean>();
return data;
}
We'll see about adding support for ScriptableObject inManage Types in Easy Save v2.6.6 so it automatically does this for you.
It will only save and load the isEnabled variable of your ScriptableObject, because that's the only variable you've told the ES2Type to save.
If you want to save other variables, you'll need to tick them in Manage Types (if they're supportable), or manually add the Read and Write methods as per the instructions here.
If you paste your ScriptableObject class here, and let me know what needs to be saved, I'll see if I can assist with this.
using UnityEngine;
using System.Collections;
using System;
[Serializable]
public class DickyAsset:ScriptableObject,IComparable {
public enum AssetType
{
GLASSES,
HAT,
BODY,
}
public AssetType assetType;
public int id;
public Sprite sprite;
public Sprite smallPreview;
public int prize;
public bool isEnabled;
public Vector3 offSet;
public string GetCompletedID()
{
return id.ToString("000") + "@" + assetType.ToString();
}
int IComparable.CompareTo(object obj)
{
DickyAsset asset = (DickyAsset)obj;
return String.Compare(this.sprite.name,asset.sprite.name);
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ES2UserType_DickyAsset : ES2Type
{
public override void Write(object obj, ES2Writer writer)
{
DickyAsset data = (DickyAsset)obj;
// Add your writer.Write calls here.
writer.Write(data.isEnabled);
}
public override object Read(ES2Reader reader)
{
DickyAsset data = ScriptableObject.CreateInstance<DickyAsset>();
// Add your reader.Read calls here and return your object.
data.isEnabled = reader.Read<System.Boolean>();
return data;
}
/* ! Don't modify anything below this line ! */
public ES2UserType_DickyAsset():base(typeof(DickyAsset)){}
}
ScriptableObjects are supported, you will just need to select what variables of the ScriptableObject you want to save in the Assets > Easy Save 2 > Manage Types window.