Tz2/Assets/New/Scripts/OverlayToRenderTexture.cs

17 lines
384 B
C#

using UnityEngine;
using UnityEngine.Rendering.Universal;
using UnityEngine.UI;
public class OverlayToRenderTexture : MonoBehaviour
{
public RenderTexture targetRenderTexture;
private void Start()
{
// 获取相机组件
Camera camera = GetComponent<Camera>();
// 设置渲染目标为RenderTexture
camera.targetTexture = targetRenderTexture;
}
}