0

I am using the post processing tool to change the colors of my scene (My scene includes an AR camera, the only main component).

My aim is to change the hue of the scene using sliders. The tool allows me to do it while building it but I want to make sure that I allow the user to change the hue as per their choice (trying to build a color blindness correction app).

For example, if a person suffers from Deuteranopia and let's say a hue shift of -35 partially allows them to see the colors which would not be in the case of some other person with same type of colorblindness, the hue might defer.

So, I want your help in creating a post processing utility package controller that would allow me to control the hue shift using UI Sliders.

Thank you.

As you can see my inspector here, i want to have the same slider control on my canvas:

As you can see my inspector here, i want to have the same slider control on my canvas, hue shift only

tk421
  • 5,775
  • 6
  • 23
  • 34

1 Answers1

-1

How can you do it?

  1. Make a Slider: Image
  2. Set the min and max values to -255, 255 respectively: Image
  3. Add a new script called "HueFromSlider": Image
  4. Add this code to the script:


    using UnityEngine;
    using UnityEngine.PostProcessing;
    using UnityEngine.UI;

    public class HueFromSlider : MonoBehaviour 
    {
        public PostProcessingProfile profile; // A reference to the profile
        ColorGradingModel model; // The color grading model
        ColorGradingModel.Settings settings; // The color grading model settings.

        public Slider slider; // A reference to the slider so that on start it goes back to were it was.

        private void Start()
        {
            model = profile.colorGrading; // Set the model
            settings = model.settings; // Set the settings
            if (slider != null) // Set the slider back to what it was only if it has been referenced.
                slider.value = settings.basic.hueShift;
        }

        public void ChangeHue(float hue)
        {
            settings.basic.hueShift = hue; // Set the hue in the settings
            model.settings = settings; // Set the settings of the model
            profile.colorGrading = model; // set the profile model to the model
        }
    }

  1. Create a new Post processing profile if you don't have one: Go to the project, right click and select Create>Post-Processing Profile.
  2. In the inspector, drag the profile to the script and optionally the slider.
  3. In the slider, add an "On Value Changed" callback to "the script">ChangeHue. Make sure you select it as a dynamic float. It should look like this: Image
  4. Done.


Or a premade package by me: https://drive.google.com/open?id=1coTuy2M5Jlrpvm-vOu3F3B_liddrA19t

Chik3r
  • 380
  • 1
  • 11