Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug Instantiated VisualEffect does not render quad during runtime until change is made in inspector

Discussion in 'Visual Effect Graph' started by scorpioservo, Aug 4, 2022.

  1. scorpioservo

    scorpioservo

    Joined:
    Jul 24, 2020
    Posts:
    13
    I have a VisualEffect that is instantiated at runtime and it does not render the particles unless I change any property in the inspector. As soon as I tweak any of the properties, all of the active particles suddenly start to render and everything works fine. Also, I can see that the particles particles are spawning correctly and exist from the gizmos.

    This bug only appears to happen when the VisualEffect is instantiated at runtime. If it exists as a part of the scene at start, it works fine.

    I have attempted to call Reinit and ResetOverride at runtime with no success..

    I am running Unity 2021.3.6f1, HDRP, with Visual Effect Graph 12.1.7

    Any idea how I can fix this?
     
  2. melong

    melong

    Joined:
    Sep 2, 2011
    Posts:
    22
    Are you by any chance calling renderer.material on the VisualEffect component ?
    I had the same problem because of that. apparently it clones the material used by the renderer (as expected when you modify a material at runtime) but the vfx graph doesn't know about it so it leads to a desynchronization.
     
    scorpioservo likes this.
  3. scorpioservo

    scorpioservo

    Joined:
    Jul 24, 2020
    Posts:
    13
    I'm pretty sure I'm not doing that in this case, but thanks for the tip! The only script calls I am making on the VisualEffect object is a couple SetProperty type calls. But setting the property in script does not fix the rendering. Only setting the property in inspectoe.
     
  4. scorpioservo

    scorpioservo

    Joined:
    Jul 24, 2020
    Posts:
    13
    So you were actually right about this one! Turns out there was a script that was modifying all of the GameOobject's renderers' materials at runtime. Once I made sure to omit the VisualEffect renderer, everything works fine!

    Thank you!!