using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Paint : MonoBehaviour
{
public new Material paintey;
public new Slider Slider_R;
public new Slider Slider_G;
public new Slider Slider_B;
private byte Value_R;
private byte Value_G;
private byte Value_B;
private Color PaintColor;
private void Start()
{
}
private void Update()
{
PaintColor = new Color32(1, Value_R, Value_G, Value_B);
/*
Eventually, the value of Value_R, Value_G, and Value_B
must be equal to the Value of their appropriate sliders.
Value_R = Slider_R.value;
*/
paintey.SetColor("PaintColor", PaintColor);
}
}
I’m trying to get the float values from the Sliders to edit the values of the Color32,
Unfortunately the sliders outgive Float values, and the Color32 system only accepts bytes.
I need some help converting a float to a byte.
Thanks in advance.
However I’ll also mention this. Color uses a value from 0-1. Color32 uses a value from 0-255. So there are two ways you could address this. First, let your sliders be whole numbers only from 0 - 255. (also pretty easy)
Or, convert your float into the a whole number that you can use.
Simple math is x / 255 = a float value.
To get the value you want, you solve for x.
Your float value * 255 = x.