Search Unity

Set different Colors across instances via script

Discussion in 'Visual Effect Graph' started by Livealot, Apr 16, 2020.

  1. Livealot

    Livealot

    Joined:
    Sep 2, 2013
    Posts:
    228
    Quick Scenario, I want 10 different explosions on screen, each with a different color and slightly different values for exposed properties in my VFX graph.

    Coming from ShaderGraph, I know how to dynamically assign different colors using MaterialBlock.SetColor

    How do I do that in VFXgraph? There's a code example in the docs for eventAttributes, but not properties.

    There's also no SetColor, so I'm assuming we should use SetVector4(property,value)???

    Also, when working with multiple cloned instances , it's odd that group editing does not allow toggling all the properties.
     
    Last edited: Apr 16, 2020
  2. coskuturhan

    coskuturhan

    Joined:
    Dec 9, 2016
    Posts:
    13
    You would create a color parameter that is exposed. Pipe that parameter to set color in the update particle block. Then in your C# script you would change that color via VisualEffect.SetColor("ParamName",[value])
     
  3. Livealot

    Livealot

    Joined:
    Sep 2, 2013
    Posts:
    228
    AlterMannn likes this.
  4. coskuturhan

    coskuturhan

    Joined:
    Dec 9, 2016
    Posts:
    13
    Sorry I see your issue. Yeah you're right, vector4 should set the color.