22 lines
600 B
C#
22 lines
600 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
namespace BITKit
|
|
{
|
|
|
|
public static partial class TextureHelper
|
|
{
|
|
public static Texture2D ToTexture2D(this RenderTexture rTex)
|
|
{
|
|
Texture2D tex = new Texture2D(rTex.width, rTex.height, TextureFormat.RGB24, false);
|
|
var old_rt = RenderTexture.active;
|
|
RenderTexture.active = rTex;
|
|
|
|
tex.ReadPixels(new Rect(0, 0, rTex.width, rTex.height), 0, 0);
|
|
tex.Apply();
|
|
|
|
RenderTexture.active = old_rt;
|
|
return tex;
|
|
}
|
|
}
|
|
} |