这里介绍两种旋转天空盒的方式:
1:动态更改天空盒shader的参数_Rotation:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class skyBoxRotate : MonoBehaviour {
float num;
// Update is called once per frame
void Update ()
{
num = RenderSettings.skybox.GetFloat("_Rotation");
RenderSettings.skybox.SetFloat("_Rotation", num + 0.05f);
}
}
2:用两个camera协同合作来弄。mainCamera的clear flags设为depth only 或者 don’t clear,maincamera的depth设置高于另一camera哦。另一个camera的clear flags设为skybox,并且将culling mask 设为nothing,然后用代码控制其旋转,效果就出来了;
放一张图镇镇场子: