Using UI Sliders to change Material Color32 value

Greetings…
Code

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.

I didn’t read your code, but look at this:
Unity - Scripting API: Color32 (Operators section)

@methos5k suggestion will work well.

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.

I don’t understand what you’re trying to suggest? I have the sliders set up for 0-255 with whole numbers already. My problem is that for example

Value_R = Slider_R.value

is unacceptable. For I am trying to make a float equal to a byte.
I need something that does the same as this:

Slider_R.value = (byte)Value_R;

Here’s me doing what I need, but the other way around. I would need something such as

Value_R = (float)Slider_R.value;

Am I missing something really simple here or am I just not making sense? :S

EDIT: Oh ffs, the minute I clicked Reply I think I understood it, I’ll report back in a bit

I’m just pretty sure that that’s what the implicit operator does, but doesn’t hurt to try new things :slight_smile: