RenderSettings Skybox lerp

纵饮孤独 提交于 2019-12-12 01:54:51

问题


I want to switch my skybox from a day material to a night material for this I use :

Material night;
int skyboxflag = 0;
int flag = 0;
float t;
public float smooth = 1;

void Start () {
    night = Resources.LoadAll("Night_mat",typeof(Material))[0] as Material;

}

void Update () {
if (skyboxflag == 1) {
        if(flag == 0){
            t = Time.time;
            flag = 1;
        }
        RenderSettings.skybox.Lerp(RenderSettings.skybox, night,(Time.time - t)/smooth);
        if(Time.time - t > smooth){
            skyboxflag = 0;
        }
            }
}
void OnTriggerEnter(Collider other)
{
    if (other.gameObject.name == "Avatar") {
        skyboxflag = 1;

            }
    }

but nothing happens I keep having the day skybox.

what is the correct way to change the skybox smoothly from a material to another

Thank you

来源:https://stackoverflow.com/questions/28079579/rendersettings-skybox-lerp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!