Hey there, I have the following problem that I cannot seem to solve. I have a VFX graph with an exposed color property. This color is then given to an exposed color property of a custom shader the VFX graph uses. Additionally, I have a prefab (A) with a Visual Effect component that uses this VFX graph. Prefab A is then used as a child of two other prefabs, B and C. Via code, I set the color for the Visual Effect for prefab B to green:
_visualEffect.SetVector4("My Color", _green);
Where _visualEffect refers to the Visual Effect component of prefab A that is the child of prefab B. This works fine. In the inspector, the Visual Effect component shows green as the chosen color, and in the scene view, the game view, as well as the build, the effect appears green. Now, via code, I set the color for the Visual Effect for prefab C to blue:
_visualEffect.SetVector4("My Color", _blue);
Where _visualEffect refers to the Visual Effect component of prefab A that is the child of prefab C. This is where it gets weird. In the inspector, the Visual Effect component shows blue as the chosen color. However, in the scene view, the game view, and the build, the color switches between green and blue. This switching is especially weird because sometimes it only happens in the scene view while the game view shows the correct blue color, and other times it only happens in the game view while the scene view shows the correct blue color. A few times, it was also switching in both views, but at different intervals. I have tried to set the color in the renderer with:
GetComponent<Renderer>().material.SetColor("My Color", _blue);
That fixed the problem above but gave me another problem. Now, some of the visual effects cannot be seen, although the game objects that contain them are active and the color is set correctly in the inspector. If I play around with the color property in the inspector, the Visual Effect is immediately visible again. Once I restart the game (without closing Unity), it is also immediately visible with the correct color. Once I restart Unity completely, it is invisible again until I play around with the inspector property. I am VERY clueless as to what is happening. Does anyone know what kind of wizardry is happening here? I really appreciate any kind of intel and fixes!
I am using URP and Output ParticleStrip Unlit Quad