There is only a default camera and a single GameObject.
Why destroyed game objects are still in-memory ? I've tried to call the GC manually, Resources.UnloadUnusedAssets and a bunch other hacks without success. My game needs to create GameObjects on the fly... ObjectPooling of course could be done but since the player will be playing for hours and there are tons of different sprites I think this would still be a problem.
public class Game : MonoBehaviour
{
private List<GameObject> objects;
// Use this for initialization
void Start()
{
this.objects = new List<GameObject>();
}
// Update is called once per frame
void Update()
{
foreach (var item in this.objects)
{
Destroy(item);
}
this.objects = new List<GameObject>();
for (var i = 0; i <= 1000; i++)
{
GameObject gb = new GameObject();
gb.name = i.ToString();
SpriteRenderer renderer = gb.AddComponent<SpriteRenderer>();
renderer.sprite = Resources.Load("Sprites/grass", typeof(Sprite)) as Sprite;
gb.transform.position = new Vector3(i, transform.position.y, transform.position.z);
this.objects.Add(gb);
}
}
}