import pmx plugin
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public static class Texture2DExtension
|
||||
{
|
||||
public static Texture2D CreateReadabeTexture2D(this Texture2D texture2d)
|
||||
{
|
||||
RenderTexture renderTexture = RenderTexture.GetTemporary(
|
||||
texture2d.width,
|
||||
texture2d.height,
|
||||
0,
|
||||
RenderTextureFormat.Default,
|
||||
RenderTextureReadWrite.Linear);
|
||||
|
||||
Graphics.Blit(texture2d, renderTexture);
|
||||
RenderTexture previous = RenderTexture.active;
|
||||
RenderTexture.active = renderTexture;
|
||||
Texture2D readableTextur2D = new Texture2D(texture2d.width, texture2d.height);
|
||||
readableTextur2D.ReadPixels(new Rect(0, 0, renderTexture.width, renderTexture.height), 0, 0);
|
||||
readableTextur2D.Apply();
|
||||
RenderTexture.active = previous;
|
||||
RenderTexture.ReleaseTemporary(renderTexture);
|
||||
return readableTextur2D;
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3b8cc2a385b1d5c4fb754bc89a35af77
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user