// Update is called once per frame void Update() { if (updateEvent != null) { updateEvent(); counter--; if (counter <= 0) { //updateEvent -= dm.OnUpdate; dm = null; updateEvent = null; // the OnUpdate() will stop being called after 10 counts GC.Collect(); // we force the Garbage Collector to collect unreferenced classes, so we can ensure that the object dm is cleaned out } } for (int i = 0; i < DestroyList.Count; i++) { DestroyMe d = DestroyList [i] as DestroyMe; if (counter <= 0) { if (d.name == "berney") { DestroyList.Remove(DestroyList [i]); GC.Collect(); } } d.OnUpdate(); } }
// Update is called once per frame void Update() { if (updateEvent != null) { updateEvent(); counter--; if (counter <= 0) { //updateEvent -= dm.OnUpdate; dm = null; updateEvent = null; GC.Collect(); } } for (int i = 0; i < DestroyList.Count; i++) { DestroyMe d = DestroyList [i] as DestroyMe; if (counter <= 0) { if (d.name == "berney") { DestroyList.Remove(DestroyList [i]); GC.Collect(); } } d.OnUpdate(); } }
// Use this for initialization void Start() { dm = new DestroyMe("rob"); updateEvent += dm.OnUpdate; //dm = null; DestroyList.Add(new DestroyMe("white")); DestroyList.Add(new DestroyMe("stubbs")); DestroyList.Add(new DestroyMe("berney")); }
// Update is called once per frame void Update() { if (updateEvent != null) { updateEvent(); counter--; if (counter < 0) { dm = null; updateEvent = null; GC.Collect(); } } }
public void SetDestroyCallback(DestroyMe callback, int id) { destroyCallback = callback; poiID = id; }
// Update is called once per frame void Update() { if (updateEvent != null) { updateEvent(); counter --; if (counter <= 0) { //updateEvent -= dm.OnUpdate; dm = null; updateEvent = null; GC.Collect(); } } for (int i = 0; i < DestroyList.Count; i++) { DestroyMe d = DestroyList [i] as DestroyMe; if (counter <= 0) { if (d.name == "berney") { DestroyList.Remove(DestroyList [i]); GC.Collect(); } } d.OnUpdate(); } }
void DestroyDestroyMe() { DestroyMe destroyMe = gameObject.AddComponent <DestroyMe>(); Destroy(destroyMe); }
// Use this for initialization void Start() { dm = new DestroyMe("rob"); updateEvent += dm.OnUpdate; }