public void Remove(QBehavior script) { Objects.Remove(script.Parent); if (script is IQLoad l) { LoadObjects.Remove(l); } if (script is IQStart s) { StartObjects.Remove(s); } if (script is IQFixedUpdate u) { FixedUpdateObjects.Remove(u); } if (script is IQUpdate up) { UpdateObjects.Remove(up); } if (script is IQLateUpdate late) { LateUpdateObjects.Remove(late); } if (script is IQSprite ds) { SpriteObjects.Remove(ds); } if (script is IQGui dg) { GuiObjects.Remove(dg); } if (script is IQDestroy des) { des.OnDestroy(); DestroyObjects.Remove(des); } if (script is IQUnload un) { UnloadObjects.Remove(un); } //invokes event even if does not inherit OnDestroy script.DestroyEvent(); }