unity之动态旋转天空盒

这里介绍两种旋转天空盒的方式:

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,然后用代码控制其旋转,效果就出来了;

放一张图镇镇场子:
这里写图片描述

猜你喜欢

转载自blog.csdn.net/fenglele_fans/article/details/80834348