Code: Select all
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SaveTest : MonoBehaviour
{
void Start()
{
var list = new ConcreteList();
ES3.Save("save", list);
var list2 = ES3.Load("save", new ConcreteList());
list2.Print();
}
}
[Serializable]
public class ConcreteType
{
public string name = "test";
}
[Serializable]
public class ThisWorkList<T>
{
[SerializeField] protected List<T> list = new();
public void Print() => Debug.Log(list.ToString());
}
[Serializable]
public class ThisDontWorkList<T> : IEnumerable<T>
{
[SerializeField] protected List<T> list = new();
public void Print() => Debug.Log(list.ToString());
public IEnumerator<T> GetEnumerator() => list.GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => list.GetEnumerator();
}
[Serializable]
public class ConcreteList : ThisDontWorkList<ConcreteType>
{
}