本文整理汇总了C#中ObjectPool.GetPooledObject方法的典型用法代码示例。如果您正苦于以下问题:C# ObjectPool.GetPooledObject方法的具体用法?C# ObjectPool.GetPooledObject怎么用?C# ObjectPool.GetPooledObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectPool
的用法示例。
在下文中一共展示了ObjectPool.GetPooledObject方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
}
示例2: 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);
}