using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
|
namespace vnxbqy.UI
|
{
|
public static class LifeBarPool
|
{
|
const int poolSize = 10;
|
static GameObjectPoolManager.GameObjectPool pools = null;
|
|
public static LifeBar Require(LifeBar.Pattern _pattern)
|
{
|
var patternToInt = (int)_pattern;
|
if (pools == null)
|
{
|
var prefab = UILoader.LoadPrefab(ParsePrefabName(_pattern));
|
if (prefab != null)
|
{
|
pools = GameObjectPoolManager.Instance.RequestPool(prefab);
|
}
|
}
|
|
if (pools != null)
|
{
|
var instance = pools.Request();
|
return instance.GetComponent<LifeBar>();
|
}
|
else
|
{
|
return null;
|
}
|
}
|
|
public static void Recycle(GameObject _gameObject, LifeBar.Pattern _pattern)
|
{
|
var patternToInt = (int)_pattern;
|
|
if (pools != null)
|
{
|
pools.Release(_gameObject);
|
}
|
}
|
|
public static void Clear()
|
{
|
if (pools!=null)
|
{
|
pools.Clear();
|
pools = null;
|
}
|
}
|
|
static string ParsePrefabName(LifeBar.Pattern _pattern)
|
{
|
return StringUtility.Contact("LifeBar_", _pattern);
|
}
|
|
|
}
|
|
|
}
|