这是第一个 Unity 开放项目的repo,是 Unity 和社区合作创建的一个小型开源游戏演示,第一款游戏是一款名为 Chop Chop 的动作冒险游戏。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

33 行
913 B

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LocalPoolTester : MonoBehaviour
{
[SerializeField]
private PoolableParticle _prefab = default;
[SerializeField]
private int _initialPoolSize = 5;
private ParticlePoolSO _pool;
private ParticleFactorySO _factory;
private IEnumerator Start()
{
_factory = ScriptableObject.CreateInstance<ParticleFactorySO>();
_factory.Prefab = _prefab;
_pool = ScriptableObject.CreateInstance<ParticlePoolSO>();
_pool.name = gameObject.name;
_pool.Factory = _factory;
_pool.InitialPoolSize = _initialPoolSize;
List<PoolableParticle> particles = _pool.Request(10) as List<PoolableParticle>;
foreach (PoolableParticle particle in particles)
{
particle.transform.position = Random.insideUnitSphere * 5f;
particle.Play();
}
yield return new WaitForSecondsRealtime(5f);
_pool.Return(particles);
}
}