So the original idea was to attach the particle effect emission to the SeasonIntensitySlider, so that when the slider value is changed, the emission value is changed.
I wasn't able to get that done, so now I tried using the same input that changes the slider value to also change the emission value at the same time - which didn't work either (and was a band-aid fix as well). And I think I still got the wrong code for what I'm trying in the first place.
I attached the code below. Can anyone tell me how I can link them?
using System.Collections;
using UnityEngine.UI;
public class SeasonIntensity : MonoBehaviour
{
public Slider SeasonIntensitySlider;
public void Start()
{
SeasonIntensitySlider.onValueChanged.AddListener(delegate { ValueChangeCheck(); }); //Adds a listener to the main slider and invokes a method when the value changes.
}
public void ValueChangeCheck()
{
Debug.Log(SeasonIntensitySlider.value); // Invoked when the value of the slider changes.
}
public void Update()
{
if (Input.GetAxis("Mouse ScrollWheel") > 0f) //Foward
{
SeasonIntensitySlider.value += 0.1f;
}
if (Input.GetAxis("Mouse ScrollWheel") < 0f) //Backwards
{
SeasonIntensitySlider.value -= 0.1f;
}
if (Input.GetAxis("Mouse ScrollWheel") > 0f) //Foward
{
ParticleSystem ps = GetComponent<ParticleSystem>();
var em = ps.emission;
em.enabled = true;
em.rateOverTime += 5f;
}
if (Input.GetAxis("Mouse ScrollWheel") < 0f) //Backwards
{
ParticleSystem ps = GetComponent<ParticleSystem>();
var em = ps.emission;
em.enabled = true;
em.rateOverTime -= 5f;
}
}
}