Created
June 1, 2021 18:00
-
-
Save mminer/2b2e61f73e3cc6dc07955e1ccc80303c to your computer and use it in GitHub Desktop.
Unity component to change a visual effect's play rate.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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