using UnityEngine;

public abstract class GameMesh {
    
    protected GameObject gameObject;
    protected MeshRenderer renderer;
    protected MeshFilter filter;
    protected float z = 0.0f; //layer of the mesh
    protected bool isAddedToGame = false;

    public virtual void addToGame() {
        isAddedToGame = true;

        gameObject = new GameObject();
        renderer = gameObject.AddComponent(typeof(MeshRenderer)) as MeshRenderer;
        filter = gameObject.AddComponent(typeof(MeshFilter)) as MeshFilter;
    }

    public virtual void removeFromGame() {
        if (isAddedToGame) {
            Object.Destroy(gameObject);
            isAddedToGame = false;
        }
    }
}