1
This commit is contained in:
22
Unity/Scripts/Utility/TextureHelper.cs
Normal file
22
Unity/Scripts/Utility/TextureHelper.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user