Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static string RED_TAG => "Red";
- public static string BLUE_TAG => "Blue";
- public static string GREEN_TAG => "Green";
- [SerializeField] private Renderer rend;
- [SerializeField] private Slider redSlider;
- [SerializeField] private Slider greenSlider;
- [SerializeField] private Slider blueSlider;
- [SerializeField] private TMP_Text redSliderText;
- [SerializeField] private TMP_Text greenSliderText;
- [SerializeField] private TMP_Text blueSliderText;
- [SerializeField] private Color col;
- public static Color IntToColor(int red, int green, int blue)
- {
- float r = (float)red / 255;
- float g = (float)green / 255;
- float b = (float)blue / 255;
- Color col = new Color(r, g, b);
- return col;
- }
- void SetCarColor(int red, int green, int blue)
- {
- Color col = IntToColor(red, green, blue);
- rend.material.color = col;
- PlayerPrefs.SetInt("Red", red);
- PlayerPrefs.SetInt("Green", green);
- PlayerPrefs.SetInt("Blue", blue);
- }
- public static Color GetCarColor()
- {
- return IntToColor(
- PlayerPrefs.GetInt("Red"),
- PlayerPrefs.GetInt("Green"),
- PlayerPrefs.GetInt("Blue")
- );
- }
- private void Start()
- {
- rend.material.color = GetCarColor();
- redSlider.value = (int)(col.r * 255f);
- greenSlider.value = (int)(col.g * 255f);
- blueSlider.value = (int)(col.b * 255f);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement