Search Unity

  1. Curious about what's going to be in 2021.1? Have a look at the 2021.1 beta blog post.
    Dismiss Notice

VFX Graph - How do I access the VFXEventAttribute payload?

Discussion in 'Graphics Experimental Previews' started by turboturboturbo, Oct 4, 2019.

  1. turboturboturbo

    turboturboturbo

    Joined:
    Dec 2, 2018
    Posts:
    21
    I want to spawn hundreds of explosions in quick succession.
    Each explosion varies in position, duration, color, intensity etc...

    Currently I am instantiating a new VFX graph object for each explosion and changing their exposed parameters, however this seems like a bad idea?

    Instead I would like to create a single VFX graph and send VFXEventAttributes as parameters:

    Code (CSharp):
    1. string eventName = "OnExplode"
    2. void SendEvent(string eventName, VFXEventAttribute eventAttribute = null);
    My question: How can I access these attributes/values within the blocks?
     
    Last edited: Oct 4, 2019
  2. JulienF_Unity

    JulienF_Unity

    Unity Technologies

    Joined:
    Dec 17, 2015
    Posts:
    217
    You can access it in the initialize context using get source attribute
     
  3. turboturboturbo

    turboturboturbo

    Joined:
    Dec 2, 2018
    Posts:
    21
    Hi Julien,

    When I do the following:
    Code (CSharp):
    1. _attrib = _vfx.CreateVFXEventAttribute();        
    2. _attrib.SetVector3("color-1", color);
    3. _vfx.SendEvent("OnManualSpawn", _attrib);
    I can't find the attribute "color-1" in the node graph editor. Am I misunderstanding how this works?
     
  4. JulienF_Unity

    JulienF_Unity

    Unity Technologies

    Joined:
    Dec 17, 2015
    Posts:
    217
    You need to use custom attributes nodes if you're not using built-in ones. You can activate them in preferences / vfx, enable use experimental blocks / operators
     
  5. turboturboturbo

    turboturboturbo

    Joined:
    Dec 2, 2018
    Posts:
    21
    They are currently activated but the only thing I can find is "Get CustomAttribute (Float)". I cannot find the "color-1" attribute.

     
  6. JulienF_Unity

    JulienF_Unity

    Unity Technologies

    Joined:
    Dec 17, 2015
    Posts:
    217
    In the inspector, there should be an option to set the name and type of your custom attribute
     
  7. turboturboturbo

    turboturboturbo

    Joined:
    Dec 2, 2018
    Posts:
    21
    Thank you. I am able to set up the custom attribute getter, however it doesn't seem to work. Do you see anything wrong here?

    Code (CSharp):
    1.  
    2. //this is called rapidly with different parameter values
    3. public void Activate(float duration, Vector3 color, Vector3 position)
    4.     {
    5.         _attrib = _vfx.CreateVFXEventAttribute();
    6.         _attrib.SetVector3("_position", position);
    7.         _attrib.SetVector3("_color", color);
    8.         _attrib.SetFloat("_duration", duration);
    9.         _vfx.SendEvent("OnManualSpawn", _attrib);
    10.     }


     
    Last edited: Oct 5, 2019
  8. turboturboturbo

    turboturboturbo

    Joined:
    Dec 2, 2018
    Posts:
    21
  9. JulienF_Unity

    JulienF_Unity

    Unity Technologies

    Joined:
    Dec 17, 2015
    Posts:
    217
    I checked and there's is currently no way to specify source in the get custom attribute operator, this is a UI issues only but it prevents you to do what you want. Sorry about the false info. So you need to use built-in attributes at the moment (color instead of _color for instance)
     
  10. glacuesta

    glacuesta

    Joined:
    Nov 30, 2017
    Posts:
    4
    bump on this topic. Seemed like a dead end then, and it still seems like a dead end now? Basically, how does one access the event attributes (passed from script) in the node graph?
     
  11. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    740
    Was just fighting with this problem for a few hours right now.

    Everything in documentation gives the impression that it is possible to send custom attribute with event.
    First you try to find how to get custom attribute node.
    You search the forum and you find out that you have to enable experimental blocks.
    Finally you add custom attribute node and than you realize it is not possible to specify custom attribute.

    I always thought that experimental feature is something that actually is working.

    UT should add another category in addition to experimental it should be called "ToDo".
    You than would be able to download latest ToDo packages and just pretend you got it ;)
     
unityunity