我想将我的天空盒从日间材料切换为夜间材料,我将使用:
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;
}
}
但没有任何反应我继续拥有白昼天空盒。
将天空盒从一种材料平滑地更改为另一种
的正确方法是什么?谢谢