public void PushToPool() { if (this.createPool == false) { for (int i = this.subObjects.Count - 1; i >= 0; --i) { this.subObjects[i].PushToPool(); } } if (this.isObjectRoot == true) { if (this.rootObject != null) { this.rootObject.RemoveSubObject(this); } if (this.createPool == false) { this.DoDeInit(); } WindowSystem.GetPools().Despawn(this); } }
/// <summary> /// Clean up window instance. /// This instance would be removed from pools, and all resources will be free. /// </summary> /// <param name="instance"></param> public static void Clean(WindowBase instance) { instance.DoDeInit(); var pools = WindowSystem.GetPools(); pools.RemoveInstance(instance); }
public T Load <T>(T prefab) where T : WindowObject { if (prefab.createPool == true) { WindowSystem.GetPools().CreatePool(prefab); } var instance = WindowSystem.GetPools().Spawn(prefab, this.transform); instance.Setup(this.GetWindow()); instance.SetInvisible(); this.RegisterSubObject(instance); return(instance); }