unityRenderTexture的使用
Posted 那个妹子留步
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了unityRenderTexture的使用相关的知识,希望对你有一定的参考价值。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class NewBehaviourScript : MonoBehaviour
public RawImage RawImage;
public Camera Camera;
private RenderTexture _renderTexture;
// Start is called before the first frame update
void Start()
_renderTexture = new RenderTexture(256,256,0);
Camera.targetTexture = _renderTexture;
RawImage.texture = _renderTexture;
// Update is called once per frame
void Update()
if (Input.GetKeyDown(KeyCode.A))
var rt= new RenderTexture(1256, 1256, 0);
Camera.targetTexture = rt;
RawImage.texture = rt;
//释放
_renderTexture.Release();
DestroyImmediate(_renderTexture);
_renderTexture = null;
_renderTexture = rt;
else if (Input.GetKeyDown(KeyCode.B))
var rt = new RenderTexture(256, 256, 0);
Camera.targetTexture = rt;
RawImage.texture = rt;
_renderTexture.Release();//释放显存
DestroyImmediate(_renderTexture);//删除对象
_renderTexture = null;
_renderTexture = rt;
else if (Input.GetKeyDown(KeyCode.C))
_renderTexture.Release();
Destroy(_renderTexture);
_renderTexture = null;
以上是关于unityRenderTexture的使用的主要内容,如果未能解决你的问题,请参考以下文章