本文整理汇总了C#中ObjectPool.Init方法的典型用法代码示例。如果您正苦于以下问题:C# ObjectPool.Init方法的具体用法?C# ObjectPool.Init怎么用?C# ObjectPool.Init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectPool
的用法示例。
在下文中一共展示了ObjectPool.Init方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitPool
void InitPool ()
{
pool = new ObjectPool<DynamicBrick> (initSize, addSize);
pool.NewObject = NewDynamicBrick;
pool.Init ();
}
示例2: InitPool
void InitPool ()
{
m_Pool_Brick = new ObjectPool<Brick> (100, 20);
m_Pool_Brick.NewObject = NewBrick;
m_Pool_Brick.Init ();
}
示例3: Start
private void Start()
{
timer = Time.time + 0.4f;
naturePool = ObjectPool.CreateInstance<ObjectPool> ();
naturePool.Init (naturePrefab, 50, true);
for (int i = 0; i < 30; i++) {
GameObject pooledObject = naturePool.GetPooledObject();
if (i % 2 == 0) {
pooledObject.transform.position = new Vector3 (Random.Range(rightMinX, rightMaxX), 0, Random.Range(-85, -10));
} else {
pooledObject.transform.position = new Vector3 (Random.Range(leftMinX, leftMaxX), 0, Random.Range(-85, -10));
}
pooledObject.SetActive (true);
}
}
示例4: Start
private void Start()
{
trafficPool = ObjectPool.CreateInstance<ObjectPool> ();
trafficPool.Init (traffic, 5, true);
puddlePool = ObjectPool.CreateInstance<ObjectPool> ();
puddlePool.Init (puddle, 2, true);
rockPool = ObjectPool.CreateInstance<ObjectPool> ();
rockPool.Init (rock, 2, true);
coinPool = ObjectPool.CreateInstance<ObjectPool> ();
coinPool.Init (coin, 2, true);
if (canSpawnTree) {
treePool = ObjectPool.CreateInstance<ObjectPool> ();
treePool.Init (tree, 4, true);
}
puddleTimer = Time.time;
coinTimer = Time.time;
treeTimer = Time.time;
}
示例5: Start
//-----------------------------------------------------------------------------------
// handler functions
void Start()
{
if (instance == null)
instance = this;
if (ObjectList.Count != SizeList.Count)
Debug.LogError("ObjectPool size is invalied!");
for (int i = 0; i < ObjectList.Count; ++i)
{
var pool = new ObjectPool();
pool.Init(ObjectList[i], SizeList[i]);
poolList.Add(ObjectList[i].name, pool);
}
}
示例6: Start
private void Start()
{
pool3L = ObjectPool.CreateInstance<ObjectPool> ();
pool3L.Init (road3L, 5, true);
for (int i = 0; i < 4; i++) {
GameObject pooledObject = pool3L.GetPooledObject();
pooledObject.transform.position = new Vector3 (0, 0, -30 * i);
pooledObject.SetActive (true);
lastSpawnedObject = pooledObject;
}
pool4L = ObjectPool.CreateInstance<ObjectPool> ();
pool4L.Init (road4L, 5, true);
pool5L = ObjectPool.CreateInstance<ObjectPool> ();
pool5L.Init (road5L, 5, true);
transition3T4 = (GameObject)Instantiate (road3T4);
transition3T4.transform.SetParent (parent.transform, false);
transition3T4.SetActive (false);
transition4T5 = (GameObject)Instantiate (road4T5);
transition4T5.transform.SetParent (parent.transform, false);
transition4T5.SetActive (false);
transition5T4 = (GameObject)Instantiate (road5T4);
transition5T4.transform.SetParent (parent.transform, false);
transition5T4.SetActive (false);
transition4T3 = (GameObject)Instantiate (road4T3);
transition4T3.transform.SetParent (parent.transform, false);
transition4T3.SetActive (false);
transitionTimer = Time.time + Random.Range (5, 10);
}
示例7: LoadMagnetResource
void LoadMagnetResource ()
{
m_Magnet_Prefab = Resources.Load ("Props/Magnet") as GameObject;
m_MagnetController_Pool = new ObjectPool<MagnetController> (MAGNET_INIT_NUM, MAGNET_ADD_NUM);
m_MagnetController_Pool.NewObject = NewMagnetController;
m_MagnetController_Pool.Init ();
}
示例8: LoadCoinResource
void LoadCoinResource ()
{
m_Coin_Prefab = Resources.Load ("Props/Coin") as GameObject;
m_CoinController_Pool = new ObjectPool<CoinController> (COIN_INIT_NUM, COIN_ADD_NUM);
m_CoinController_Pool.NewObject = NewCoinController;
m_CoinController_Pool.Init ();
}
示例9: InitPools
public void InitPools ()
{
pools = new ObjectPool<PlaySoundData> (10, 5);
pools.NewObject = NewSoundData;
pools.Init ();
}
示例10: Awake
//===================================================
// UNITY METHODS
//===================================================
/// <summary>
/// Awake.
/// </summary>
void Awake()
{
EnemyList = new List<GameObject>();
objectPool = GetComponent<ObjectPool>();
objectPool.Init();
}