Code: Select all
public class EntityManager
{
static EntityManager globalEntityManagerInstance;
public List<Entity> entities = new List<Entity>();
}
public class Entity
{
public int health;
public void OnLoad {Debug.Log("Loaded");}
}
EntityManager.globalEntityManagerInstance = new EntityManager();
Entity e = new Entity();
e.health = 1234;
EntityManager.globalEntityManagerInstance.entities.Add(e);
QUESTIONS:
1. To save this non-Monobehavior class, it is correct to write ES3.Save("EntityManager", EntityManager.globalEntityManagerInstance); ?
2. When loading, EntityManager.globalEntityManagerInstance may or may not already exist. How do I ensure there is exactly one instance of this class?
3. If I use ES3.LoadInto("EntityManager", EntityManager.globalEntityManagerInstance); is that going to overwrite what is already there ?
4. A lot of the times after loading I want to perform some kind of operation - in the above example it would be Entity.OnLoad(). How do I do that?