This commit is contained in:
CortexCore
2024-11-03 16:42:23 +08:00
commit b125894cc3
5904 changed files with 1070129 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
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;
}
}
}