This tutorial will walk through how you can tint your webcam video using a UI slider in Unity. You'll be using a RawImage to show your WebCamTexture, and you want to control its color temperature (cool → warm) with a slider.
In order to set a webcam window please refer to this page and use the camera to world scene
In the Hierarchy, right-click → UI > Slider
Rename it: ColorTempSlider
In the Inspector:
Set Min Value = -1
Set Max Value = 1
Set Value = 0 (middle = neutral)
This gives you a range from -1 (cool) to +1 (warm)
In the Project window:
- Right-click in a folder → Create > C# Script
- Name it: WebcamColorTintController
Double-click it to open the script and replace everything with this:
using UnityEngine;
using UnityEngine.UI;
public class WebcamColorTintController : MonoBehaviour
{
public RawImage webcamRawImage; // This is your video display
public Slider colorTempSlider; // This is your slider
void Start()
{
// When the slider value changes, call UpdateTint()
colorTempSlider.onValueChanged.AddListener(UpdateTint);
// Set the initial color (neutral)
UpdateTint(colorTempSlider.value);
}
void UpdateTint(float value)
{
// Define cool and warm tints
Color coolColor = new Color(0.8f, 0.9f, 1.2f); // bluish
Color warmColor = new Color(1.2f, 1.0f, 0.8f); // orangey
// Convert slider value (-1 to 1) → range (0 to 1)
float lerpValue = (value + 1f) / 2f;
// Pick the color between cool and warm
Color finalTint = Color.Lerp(coolColor, warmColor, lerpValue);
// Apply the tint to the RawImage
webcamRawImage.color = finalTint;
}
}
In the Hierarchy, create a new empty GameObject:
Right-click → Create Empty
Name it: ColorTintController
Drag the WebcamColorTintController script onto it
In the Inspector for ColorTintController, you'll see:
A field for Webcam Raw Image
A field for Color Temp Slider
Drag and drop:
Your RawImage object (the one showing webcam) into webcamRawImage
Your Slider into colorTempSlider
Move the slider left and right
Watch the live video get cooler or warmer
Added by : Eunjin Hong 2025/04/27