Posts

Showing posts with the label vfx graph

combining png file textures and the Streaming Assets folder

Below is some code that takes whatever pngs you put in the Streaming Assets folder, puts them all into one texture and assigns them to a File Texture  input for a Visual FX graph. Certain things like resolution have been hardcoded into this script, so you might want to alter those numbers. You'll want to use the flipbook image so that each image can be used seperately (or not), as sprites. This should work with normal particles as well, if altered a bit.     using System.Collections; using System.Collections.Generic; using UnityEngine; using System.IO; using UnityEngine.UI; using UnityEngine.Networking; using UnityEngine.VFX; using UnityEngine.Rendering; using UnityEngine.Rendering.HighDefinition; public class multiTextureScan : MonoBehaviour {     public VisualEffect _visualEffect;     public Dictionary<string, Texture2D> textures = new Dictionary<string, Texture2D>();     // Source textures.     pub...

setting VFX graph properties using C#

How to set values for your custom properties in VFX Graph. Yeah, there are binders, but I find they expect a rather precise  way of working.. Making your own scripts forces Unity to do what you actually want haha. In my VFX graph, I have a VECTOR 3 value named "realSpawnPos" which I'm using as the spawn position for some particles. It's important to note that "position", whilst it is a Vector3.. doesn't like receiving Vector 3 values. So make sure you set it up as a Vector 3 in the VFX graph. Further to this - Make sure in the VFX Graph, your position node is set to WORLD, if you need to set/get/whatever the world position and not local... your objects are probably nested in a million groups/transforms..   using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.VFX; public class bindPosition : MonoBehaviour {     public GameObject target_thing;     public VisualEffect visualEffect;     void U...

vfx graph particles disappear when camera moves

 So my particles kept vanishing when I moved or rotated the camera. It turns out the bounds of my particles weren't being set - despite having set a "set position" AA box beneath. Make sure you set the bounds as well!! Plugging in the same AA Box should do the trick. Think of it like setting the Flip fluid domain in Houdini, only the fluid will vanish if you step out of it haha.

Messing with VFX Graph time scale/playback rate

Unity Forum user Olmi did a nice code snippet for this https://forum.unity.com/threads/what-is-the-right-way-to-pause-particles.837889/ using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.VFX; public class vfxgraph_playrate : MonoBehaviour {     [SerializeField] float timeScale = 1.0f;     [SerializeField] VisualEffect VFX;     void Start()     {         VFX = GetComponent<VisualEffect>();     }     void Update()     {         VFX.playRate = timeScale;     } } NEAT AS HECK. WHY ISN'T THIS A NODE IN VFX GRAPH?

slider UI event/functions

Here's a way to get sliders to control VFX graph values   using UnityEngine; using System.Collections; using UnityEngine.UI; // Required when Using UI elements. using UnityEngine.VFX; using UnityEngine.Rendering; using UnityEngine.Rendering.HighDefinition; public class slider_ctrl : MonoBehaviour {     public Slider _mainSlider;     public VisualEffect _visualEffect;     public Volume _volume;     [SerializeField]     private float _whateverValue = 0;     public void Start()     {         //Adds a listener to the main slider and invokes a method when the value changes.         _mainSlider.onValueChanged.AddListener(delegate { ValueChangeCheck(); });     }     // Invoked when the value of the slider changes.     public void ValueChangeCheck()     { ...