コード例 #1
0
    private void Start()
    {
        _factory              = ScriptableObject.CreateInstance <ParticleFactorySO>();
        _pool                 = ScriptableObject.CreateInstance <ParticlePoolSO>();
        _pool.name            = gameObject.name;
        _pool.Factory         = _factory;
        _pool.InitialPoolSize = _initialPoolSize;
        List <ParticleSystem> particles = _pool.Request(10) as List <ParticleSystem>;

        foreach (ParticleSystem particle in particles)
        {
            StartCoroutine(DoParticleBehaviour(particle));
        }
    }
コード例 #2
0
    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);
    }
コード例 #3
0
    private IEnumerator Start()
    {
        _factory      = ScriptableObject.CreateInstance <ParticleFactorySO>();
        _pool         = ScriptableObject.CreateInstance <ParticlePoolSO>();
        _pool.name    = gameObject.name;
        _pool.Factory = _factory;
        _pool.SetParent(this.transform);
        _pool.Prewarm(_initialPoolSize);
        List <ParticleSystem> particles = _pool.Request(2) as List <ParticleSystem>;

        foreach (ParticleSystem particle in particles)
        {
            StartCoroutine(DoParticleBehaviour(particle));
        }
        yield return(new WaitForSeconds(2));

        _pool.SetParent(null);
        yield return(new WaitForSeconds(2));

        _pool.SetParent(this.transform);
    }