Search Unity

  1. Click here to see what's on sale for the "Best of Super Sale" on the Asset Store
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

VFX Graph - How can I dynamically stop specific events?

Discussion in 'General Graphics' started by turboturboturbo, Jan 22, 2020.

  1. turboturboturbo

    turboturboturbo

    Joined:
    Dec 2, 2018
    Posts:
    20
    I want to create X number of particle emissions.
    Each emission varies in color, and position.

    In my VFX Graph instance I create these emissions like so:

    Code (CSharp):
    1.     public void CreateEmission(Color color, Vector3 position)
    2.     {
    3.         VFXEventAttribute _attrib = vfx.CreateVFXEventAttribute();
    4.         _attrib.SetVector3("position", position);
    5.         _attrib.SetVector3("color", new Vector3(color.r, color.g, color.b));
    6.         vfx.SendEvent("OnManualSpawn", _attrib);
    7.     }
    8.  
    So let's say I call this 3 times, I now have 3 different emissions running.


    Now I want to dynamically stop emission #1. How can I do this?

    Currently I am instantiating and then destroying a new VFX Graph instance for every event! But this seems wrong. Is it possible to do this within a single VFX Graph instance??
     
    Last edited: Jan 23, 2020
unityunity