using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class PhotoShopCamera : MonoBehaviour { public Camera shotCam; public Action onRenderFinish; public void Awake() { shotCam = GetComponent(); } public void OnPostRender() { //设定当前RenderTexture为快照相机的targetTexture RenderTexture rt = shotCam.targetTexture; RenderTexture.active = rt; Texture2D tex = new Texture2D(rt.width, rt.height); //读取缓冲区像素信息 tex.ReadPixels(new Rect(0, 0, rt.width, rt.height), 0, 0); tex.Apply(); if (onRenderFinish != null) { onRenderFinish.Invoke(tex); } Destroy(tex); } }