public void OnDestroy() { if (_system != null) { _system.Destroy(); _system = null; } }
public static GameObject Create(EcsSystem ecsSystem, string name = null) { if (ecsSystem == null) { throw new ArgumentException("EcsSystem"); } var go = new GameObject(name != null ? string.Format("[EcsSystem{0}]", name) : "[EcsSystem]"); DontDestroyOnLoad(go); go.hideFlags = HideFlags.NotEditable; var observer = go.AddComponent <EcsSystemObserver>(); observer._system = ecsSystem; return(go); }