Still working on my Crosshair customizer, heres the problem:
I made two functions which change the color of the crosshair
public void SliderColorChange()
{
PlayerPrefs.SetFloat("crosshairred", RedSlider.value);
PlayerPrefs.SetFloat("crosshairgreen", GreenSlider.value);
PlayerPrefs.SetFloat("crosshairblue", BlueSlider.value);
Color crosshaircolor = new Color(RedSlider.value, GreenSlider.value, BlueSlider.value);
RedInput.text = (RedSlider.value * 255).ToString();
GreenInput.text = (GreenSlider.value * 255).ToString();
BlueInput.text = (BlueSlider.value * 255).ToString();
upper.color = crosshaircolor;
lower.color = crosshaircolor;
left.color = crosshaircolor;
right.color = crosshaircolor;
}
public void InputColorChange()
{
PlayerPrefs.SetFloat("crosshairred", float.Parse(RedInput.text) / 255);
PlayerPrefs.SetFloat("crosshairgreen", float.Parse(GreenInput.text) / 255);
PlayerPrefs.SetFloat("crosshairblue", float.Parse(BlueInput.text) / 255);
Color crosshaircolor = new Color(float.Parse(RedInput.text) / 255, float.Parse(GreenInput.text) / 255, float.Parse(BlueInput.text) / 255);
RedSlider.value = float.Parse(RedInput.text) / 255;
GreenSlider.value = float.Parse(GreenInput.text) / 255;
BlueSlider.value = float.Parse(BlueInput.text) / 255;
upper.color = crosshaircolor;
lower.color = crosshaircolor;
left.color = crosshaircolor;
right.color = crosshaircolor;
}
The first one uses sliders to change the color, of which I have three (for every color channel) using this exact function. The second one uses Input fields. Now, whenever I use the sliders or the Input fields, the color of the crosshair does change, but the green and blue values don’t save into PlayerPrefs (when I read it after exiting and reentering play mode both of them are zero, even though I changed them to another value), however, the value for the red channel does save.
Anyone know what the issue could be? Should I maybe split up both functions into three different ones to change every color channel with a seperate function?