- Home /
rendersettings.skybox not working? c#
Ok so its a bit strange that render settings is not working, the main reason being is I have the exact same script in my other game and it works fine, its a simple script. basically what happens is if I write the script the skybox will just give the default blue, I have been at this for hours, I've read everything online and can not find out what's going on. the materials have been set in the inspector and everything checked and double checked.
I will write the script how I wrote it in Unity. public Material dayMat; public Material nightMat
void Update () { if (Clock.hours >= 5 || Clock.hours <= 21) { RenderSettings.skybox = dayMat; } else { RenderSettings.skybox = nightMat;
}
}
all this does is return the default blue sky and very strange I have the same script in my other game?
does anyone have the same problem or know anything ? thanks in advance.
Answer by pronobroy · Jun 26, 2016 at 09:33 AM
public Material mat;
public Material day;
public Material skyBox;
5.
float t = 0.02f;
float a;
// Use this for initialization
void Start ()
10. {
RenderSettings.skybox.Lerp(skyBox, mat, 0.5f); //Here assaying mat matiral as default .
}
// Update is called once per frame
15. void Update ()
{
a = (Time.time *4) % 360;
transform.eulerAngles = new Vector3(transform.rotation.x + a , transform.rotation.y, transform.rotation.z);
20.
if(a > 25 && a < 150 )
{
//Changing default to day matiral skybox.
25. RenderSettings.skybox.Lerp(skyBox,day,0.5f * Time.deltaTime);
}
else if (a > 150 && a < 185)
{
30. //Changing day matiral to mat matiral
RenderSettings.skybox.Lerp(skyBox,mat,0.5f*Time.deltaTime);
}
}
You can try this for changing skybox.
Thank you for the answer pronobroy, but my script works in my other game and trying to figure out why its not working in my current one, but I will take some good pointers from this script, ill see what I can do with it :)
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Unity5 filled my SSD? 0 Answers
Generate floor mesh according to walls 0 Answers
Unity 5 - Adding a Pre-made Countdown Timer C# Script to the Game Scene as a Text UI Element 1 Answer