Skip to content

Instantly share code, notes, and snippets.

@mminer
Created June 1, 2021 18:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mminer/2b2e61f73e3cc6dc07955e1ccc80303c to your computer and use it in GitHub Desktop.
Save mminer/2b2e61f73e3cc6dc07955e1ccc80303c to your computer and use it in GitHub Desktop.
Unity component to change a visual effect's play rate.
using UnityEngine;
using UnityEngine.VFX;
[ExecuteInEditMode]
[RequireComponent(typeof(VisualEffect))]
public class VisualEffectPlayRate : MonoBehaviour
{
[SerializeField, Range(0, 10)] float playRate = 1f;
VisualEffect vfx;
void OnValidate()
{
vfx = GetComponent<VisualEffect>();
}
void Update()
{
vfx.playRate = playRate;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment