0

我想将我的天空盒从白天材料切换到夜间材料,为此我使用:

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;

            }
    }

但什么也没发生,我一直有白天的天空盒。

将天空盒从一种材质平滑更改为另一种材质的正确方法是什么

谢谢

4

0 回答 0