Last active
February 29, 2016 15:12
-
-
Save sukedon/fb9b4fdcc12a6dad644c to your computer and use it in GitHub Desktop.
オブジェクトプーリングに対応したパーティクル再生クラス
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
using System.Collections.Generic; | |
using System.Linq; | |
public static class ParticleManager{ | |
/// <summary> | |
/// プール用オブジェクトのリスト | |
/// </summary> | |
private static List<ParticlePooler> particlePoolerList = new List<ParticlePooler>(); | |
/// <summary> | |
/// 指定した名前のパーティクル再生 | |
/// 初めて再生するパーティクルはプール用オブジェクトを生成 | |
/// </summary> | |
/// <param name="particleName">Particle name.</param> | |
/// <param name="position">Position.</param> | |
public static void PlayParticle(string particleName,Vector3 position){ | |
//リストから指定した名前のプール用オブジェクトを取得 | |
ParticlePooler pooler = particlePoolerList.Where(tempPooler => tempPooler.ParticleName == particleName).FirstOrDefault(); | |
if(pooler == null){ | |
//取得できなければ新たに生成 | |
pooler = new ParticlePooler(particleName); | |
particlePoolerList.Add(pooler); | |
} | |
pooler.Play(position); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment