// Remove old Particle and do Create new Particle GameObject void ShowParticle() { // Keep m_ParticleType between 0 to m_ParticleTypeList.Length-1 if (m_ParticleType >= m_ParticleTypeList.Length) { m_ParticleType = 0; } else if (m_ParticleType < 0) { m_ParticleType = m_ParticleTypeList.Length - 1; } int index = 0; if (m_ParticleType != m_ParticleTypeOld) { // Disable all m_ParticleTypeList[m_ParticleTypeOld] if (m_ParticleTypeOld >= 0) { index = 0; foreach (Transform child in m_ParticleTypeList[m_ParticleTypeOld].m_Particles) { ParticleSystem pParticleSystem = child.gameObject.GetComponent <ParticleSystem>(); if (pParticleSystem != null) { pParticleSystem.Stop(); pParticleSystem.gameObject.SetActive(false); } index++; } } // Disable all m_ParticleTypeList[m_ParticleType] if (m_ParticleType >= 0) { index = 0; foreach (Transform child in m_ParticleTypeList[m_ParticleType].m_Particles) { ParticleSystem pParticleSystem = child.gameObject.GetComponent <ParticleSystem>(); if (pParticleSystem != null) { pParticleSystem.Stop(); pParticleSystem.gameObject.SetActive(false); } index++; } } if (m_ParticleTypeOld >= 0) { m_ParticleTypeList[m_ParticleTypeOld].m_Particles.gameObject.SetActive(false); } if (m_ParticleType >= 0) { m_ParticleTypeList[m_ParticleType].m_Particles.gameObject.SetActive(true); } m_ParticleTypeName = m_ParticleTypeList[m_ParticleType].m_Particles.name; m_ParticleTypeChildCount = m_ParticleTypeList[m_ParticleType].m_Particles.childCount; } // Keep m_ParticleIndex between 0 to m_ParticleTypeChildCount-1 if (m_ParticleIndex >= m_ParticleTypeChildCount) { m_ParticleIndex = 0; } else if (m_ParticleIndex < 0) { m_ParticleIndex = m_ParticleTypeChildCount - 1; } // Play ParticleSystem if (m_ParticleIndex != m_ParticleIndexOld || m_ParticleType != m_ParticleTypeOld) { // Disable Old particle if (m_Particle != null) { m_Particle.Stop(); m_Particle.gameObject.SetActive(false); } index = 0; foreach (Transform child in m_ParticleTypeList[m_ParticleType].m_Particles) { if (index == m_ParticleIndex) { m_ParticleOld = m_Particle; // Keep old TargetAnimatorEvent if (m_ParticleOld != null) { m_TargetAnimatorEvent_Old = m_ParticleOld.gameObject.GetComponent <FXQ_TargetAnimatorEvent>(); } // Play current paritcle m_Particle = child.gameObject.GetComponent <ParticleSystem>(); if (m_Particle != null) { m_Particle.gameObject.SetActive(true); m_Particle.Play(); m_ParticleName = m_Particle.name; m_ParticleDetails_Text_Name.text = m_ParticleName; m_ParticleDetails_Text_Order.text = m_ParticleTypeName + " (" + (m_ParticleIndex + 1) + " / " + m_ParticleTypeChildCount + ")"; // Keep new TargetAnimatorEvent m_TargetAnimatorEvent_Current = m_Particle.gameObject.GetComponent <FXQ_TargetAnimatorEvent>(); UpdateTargetAnimator(); } break; } index++; } } }
// Remove old Particle and do Create new Particle GameObject void ShowParticle() { // Keep m_ParticleType between 0 to m_ParticleTypeList.Length-1 if(m_ParticleType>=m_ParticleTypeList.Length) { m_ParticleType = 0; } else if(m_ParticleType<0) { m_ParticleType = m_ParticleTypeList.Length-1; } int index = 0; if(m_ParticleType!=m_ParticleTypeOld) { // Disable all m_ParticleTypeList[m_ParticleTypeOld] if(m_ParticleTypeOld>=0) { index = 0; foreach(Transform child in m_ParticleTypeList[m_ParticleTypeOld].m_Particles) { ParticleSystem pParticleSystem = child.gameObject.GetComponent<ParticleSystem>(); if(pParticleSystem!=null) { pParticleSystem.Stop(); pParticleSystem.gameObject.SetActive(false); } index++; } } // Disable all m_ParticleTypeList[m_ParticleType] if(m_ParticleType>=0) { index = 0; foreach(Transform child in m_ParticleTypeList[m_ParticleType].m_Particles) { ParticleSystem pParticleSystem = child.gameObject.GetComponent<ParticleSystem>(); if(pParticleSystem!=null) { pParticleSystem.Stop(); pParticleSystem.gameObject.SetActive(false); } index++; } } if(m_ParticleTypeOld>=0) { m_ParticleTypeList[m_ParticleTypeOld].m_Particles.gameObject.SetActive(false); } if(m_ParticleType>=0) { m_ParticleTypeList[m_ParticleType].m_Particles.gameObject.SetActive(true); } m_ParticleTypeName = m_ParticleTypeList[m_ParticleType].m_Particles.name; m_ParticleTypeChildCount = m_ParticleTypeList[m_ParticleType].m_Particles.childCount; } // Keep m_ParticleIndex between 0 to m_ParticleTypeChildCount-1 if(m_ParticleIndex>=m_ParticleTypeChildCount) { m_ParticleIndex = 0; } else if(m_ParticleIndex<0) { m_ParticleIndex = m_ParticleTypeChildCount-1; } // Play ParticleSystem if(m_ParticleIndex!=m_ParticleIndexOld || m_ParticleType!=m_ParticleTypeOld) { // Disable Old particle if(m_Particle!=null) { m_Particle.Stop(); m_Particle.gameObject.SetActive(false); } index = 0; foreach(Transform child in m_ParticleTypeList[m_ParticleType].m_Particles) { if(index==m_ParticleIndex) { m_ParticleOld = m_Particle; // Keep old TargetAnimatorEvent if(m_ParticleOld!=null) m_TargetAnimatorEvent_Old = m_ParticleOld.gameObject.GetComponent<FXQ_TargetAnimatorEvent>(); // Play current paritcle m_Particle = child.gameObject.GetComponent<ParticleSystem>(); if(m_Particle!=null) { m_Particle.gameObject.SetActive(true); m_Particle.Play(); m_ParticleName = m_Particle.name; m_ParticleDetails_Text_Name.text = m_ParticleName; m_ParticleDetails_Text_Order.text = m_ParticleTypeName + " (" + (m_ParticleIndex+1) + " / " + m_ParticleTypeChildCount + ")"; // Keep new TargetAnimatorEvent m_TargetAnimatorEvent_Current = m_Particle.gameObject.GetComponent<FXQ_TargetAnimatorEvent>(); UpdateTargetAnimator(); } break; } index++; } } }