public GameObject SpawnParticleObject(GameObject particleObj, Vector3 pos, Quaternion rot, bool isCanDestory = false) { DestroyThisTimed destroyThisCom = FindeParticleManageFromList(particleObj); if (destroyThisCom == null) { ParticleDt particleDt = new ParticleDt(); GameObject obj = (GameObject)Instantiate(particleObj, pos, rot); destroyThisCom = obj.GetComponent <DestroyThisTimed>(); obj.name = particleObj.name; particleDt.ParticleObject = obj; particleDt.DestroyThisCom = destroyThisCom; ParticleDtList.Add(particleDt); destroyThisCom.Init(isCanDestory); } else { destroyThisCom.transform.position = pos; destroyThisCom.transform.rotation = rot; } destroyThisCom.PlayGamePartidle(); return(destroyThisCom.gameObject); }
DestroyThisTimed FindeParticleManageFromList(GameObject particleObj) { try { ParticleDt particleDt = ParticleDtList.Find( delegate(ParticleDt objTmp) { return(objTmp.ParticleObject.name == particleObj.name); }); if (particleDt != null) { return(particleDt.DestroyThisCom); } else { return(null); } } catch (System.Exception ex) { Debug.LogError("Unity: -> " + ex); throw; } }