您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
39 行
987 B
39 行
987 B
using UnityEngine;
|
|
using UnityEngine.Rendering;
|
|
|
|
[ExecuteAlways]
|
|
public class SkyboxSystem : MonoBehaviour
|
|
{
|
|
public int scalefactor = 64;
|
|
|
|
public Renderer[] renderList;
|
|
|
|
private void OnEnable()
|
|
{
|
|
RenderPipelineManager.beginCameraRendering += OnCamera;
|
|
RenderPipelineManager.endCameraRendering += OnCameraFinish;
|
|
|
|
CollectRenderers();
|
|
}
|
|
|
|
private void CollectRenderers()
|
|
{
|
|
renderList = GetComponentsInChildren<Renderer>();
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
RenderPipelineManager.beginCameraRendering -= OnCamera;
|
|
RenderPipelineManager.endCameraRendering -= OnCameraFinish;
|
|
}
|
|
|
|
private void OnCamera(ScriptableRenderContext context, Camera camera)
|
|
{
|
|
transform.position = Vector3.Lerp(camera.transform.position, Vector3.zero, 1f / scalefactor);
|
|
}
|
|
|
|
private void OnCameraFinish(ScriptableRenderContext context, Camera camera)
|
|
{
|
|
transform.position = Vector3.zero;
|
|
}
|
|
}
|