- Home /
Question by
Xyn333 · Sep 10, 2019 at 08:41 PM ·
c#uiparticlesystem
How can we use UI Sliders to control Particle System values?
I want to be able to properly control all particle system values using unity sliders UI elements, not some GUI generated or hidden method, but for UI.
There is almost nothing out there, and the getcomponent versions arent outlined correctly.
Comment
Best Answer
Answer by Xyn333 · Sep 10, 2019 at 08:45 PM
So after much attempting and attempts and many issues.
I CLICKED - and boom here is the general solve.
using UnityEngine;
using UnityEngine.UI;
public class ParticleEmitterRateScript : MonoBehaviour
{
ParticleSystem myParticleSystem;
ParticleSystem.EmissionModule emissionModule;
public Slider emitterSlider;
void Start()
{
myParticleSystem = GetComponent<ParticleSystem>();
emissionModule = myParticleSystem.emission;
}
void Update()
{
emissionModule.rate = emitterSlider.value;
}
}