- Home /
How to change or set the Ground and Sky Tint color of a Procedural Skybox through script?
Basically I'm trying to change these through my code:
Color rndCol = new Color(spawner.RandVar(1), spawner.RandVar(1), spawner.RandVar(1));
spawner.sky.SetColor("_Tint", rndCol);
RenderSettings.skybox.SetColor("_Tint", rndCol);
but I don't see anything happening. I have no idea how to access those, but I feel like I should be able to, since they even have a color picker in the editor.
I searched a lot, but couldn't find what I was looking for in the documentation, and answers to similar questions were SetColor("_Tint", color) and SetColor("_Color", color), which didn't work. I also tried SetColor("_Ground", color) and SetColor("_Sky Tint", color), in both my material and the render settings skybox, also no results.
Thanks in advance for any help.
Answer by SyFySkyEdawd · May 07, 2020 at 04:01 PM
I'm not sure how to change the ground color, but you can change the skytint with string "_SkyTint" like so.
RenderSettings.skybox.SetColor("_SkyTint", Color.black);
Keep in mind that if you change it, the change becomes permanent, even if you exit PlayMode. You might wanna cache the the color by putting in
private Color initialSkyTint;
As a field and
initialSkyTint = RenderSettings.skybox.GetColor("_SkyTint");
In Start and
RenderSettings.skybox.SetColor("_SkyTiny", initialSkyTint);
In OnDestroy/OnDisable
I'm still trying to figure out the Ground as like you said, _Ground doesn't work, but you can modify all other properties using "_Exposure", "_SunSize" and "_AtmosphereThickness".
@SyFySkyEdawd Thanks for the help, I just want to inform you that I looked at Unity's documentation and figured out for the ground property you can use "_GroundColor".