- Home /
Particle Systems wont stop/play
I'm working on a project that visualizes data from a Graphml using Force directed graph algorithm. The nodes are created with their own material and particle system. When I want to distinguish communities of nodes by a Dropdown button, the non-selected nodes need to fade. I managed to make the nodes transparent. But I cannot disable the particle system.
This is the code. The nodes are properly selected because the material loses opacity correctly. It's the particle system what I cannot disable. What do you guys think?
I'll just show the piece of code where the problem is. If you need more info, I'll update the post.
public class DropdownComm : MonoBehaviour {
public TextAsset xmlRawFile;
public Dropdown dropdown;
void Start () {
commList();
dropdown.onValueChanged.AddListener(delegate {
DropdownValueChanged(dropdown);
});
}
public void DropdownValueChanged(Dropdown change)
{
foreach (Node node in StaticUtil.NodeList)
{
if (!(dropdown.captionText.text == node.modularClass.ToString() || dropdown.value == 0))
{
node.GetComponent<Renderer>().material.color= new Color(1, 1, 1, 0.01f);
node.GetComponent<Renderer>().material.DisableKeyword("_EMISSION");
node.GetComponent<ParticleSystem>().Stop();
}
else
{
node.GetComponent<Renderer>().material.EnableKeyword("_EMISSION");
node.GetComponent<Renderer>().material.color = new Color(1, 1, 1, 1f);
node.GetComponent<ParticleSystem>().Play();
}
}
}
}
Group of nodes Not selected
Group of nodes Selected (As you see, the material is transparent but the particle system is still running)
Thanks a lot!