How can I change the hue of a scene using GUI Sliders?

Updated on March 1, 2018 in [A] Unity Scripting
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
1 on March 1, 2018

I used the post processing tool to change the hue of the scene. I wanted to change the hue from the color grading by controlling it from the UI (via sliders). How can I go about it?

  • Liked by
Reply
0 on March 1, 2018

On going through the internet, I found this code but it changes the directionalLight of the scene and yet nothing happens on the AR Camera. The post processing tool directly changed the color of the scene, how can I control that with a script (so that I can implement it in the slider)

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI; // Required when Using UI elements.

public class hueS : MonoBehaviour
{
public Slider mainSlider;
public Light directionalLight;
float H, S, V;

public void Start()
{
Color.RGBToHSV(directionalLight.color, out H, out S, out V);
//Adds a listener to the main slider and invokes a method when the value changes.
mainSlider.onValueChanged.AddListener(delegate {ValueChangeCheck(); });
}

// Invoked when the value of the slider changes.
public void ValueChangeCheck()
{
directionalLight.color= Color.HSVToRGB(mainSlider.value,S,V);
Debug.Log(mainSlider.value);
}
}

  • Liked by
Reply
Cancel