Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    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:
    25
    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:
    326
    You can access it in the initialize context using get source attribute
     
  3. turboturboturbo

    turboturboturbo

    Joined:
    Dec 2, 2018
    Posts:
    25
    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:
    326
    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
     
    GameDeveloper1111 likes this.
  5. turboturboturbo

    turboturboturbo

    Joined:
    Dec 2, 2018
    Posts:
    25
    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:
    326
    In the inspector, there should be an option to set the name and type of your custom attribute
     
    nicloay likes this.
  7. turboturboturbo

    turboturboturbo

    Joined:
    Dec 2, 2018
    Posts:
    25
    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:
    25
  9. JulienF_Unity

    JulienF_Unity

    Unity Technologies

    Joined:
    Dec 17, 2015
    Posts:
    326
    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:
    10
    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:
    2,073
    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 ;)
     
    Tibor0991 likes this.
  12. nmaltais3

    nmaltais3

    Joined:
    Feb 6, 2023
    Posts:
    1
    Any updates on being able to access the VFXEventAttribute in the graph?
     
  13. Botaurus

    Botaurus

    Joined:
    Feb 20, 2013
    Posts:
    81
    Bump, I'm trying to do this. Can't figure out how to spawn particles at different positions via events with the VFXEventAttributes
     
  14. nicloay

    nicloay

    Joined:
    Jul 11, 2012
    Posts:
    540
    Just for anyone, when you add "Get Custom Attribute" just check the Inspector column, set of properties is there, As you can see, I changed the name to my custom "TextBufferStartPosition"
    upload_2023-7-26_23-17-55.png