Example #1
0
 public SimpleObjectPool(Func <T> factoryMethod, Action <T> resetMethod = null, int initCount = 0)
 {
     _factory     = new CustomFactory <T>(factoryMethod);
     _resetMethod = resetMethod;
     for (int i = 0; i < initCount; i++)
     {
         _cacheStack.Push(_factory.Create());
     }
 }
Example #2
0
 public MonoObjectPool(Func <Object> createMethod, Action <T> onShowMethod = null, Action <T> onHideMethod = null, int initCount = 0)
 {
     _onHideMethod = onHideMethod;
     _createMehtod = createMethod;
     _onShowMethod = onShowMethod;
     _factory      = new CustomFactory <T>(Create);
     for (int i = 0; i < initCount; i++)
     {
         _cacheStack.Push(_factory.Create());
     }
 }