Hello everyone;
I ‘m working on 2D game in Unity and I’ m wondering how we can manage brightness with a slider which is in the option menu of my game. I wanted to know what are the steps to solve this problem.
Regards
t-yacine
Hello everyone;
I ‘m working on 2D game in Unity and I’ m wondering how we can manage brightness with a slider which is in the option menu of my game. I wanted to know what are the steps to solve this problem.
Regards
t-yacine
You could try changing RenderSettings.ambientlight.
Have a slider from 0 to 1. Then create a new color with that value and apply it.
i.e RenderSettings.ambientlight = new Color(sliderValue, sliderValue, sliderValue, 1.0f);
This what I did but it doesn’t seems to work. First, i wrote this code :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Brightness : MonoBehaviour { float rgbValue = 0.5f;
public void onGUI()
{
rgbValue = GUI.HorizontalSlider(new Rect(Screen.width / 2 - 50, 90, 100, 90), rgbValue, 0f, 1.0f);
RenderSettings.ambientLight = new Color(rgbValue, rgbValue, rgbValue, 1);
}
}
I add this component to the directionnal light. However, when I want to apply this funtion to the slider (the slider is in the option menu) in the "on value changed ", I can’t find the function i’v coded. So I can’t try if my code is correct. Could give a solution to solve my problem.
Regards.
t-yacine