111
This commit is contained in:
8
Assets/ThirdParty/Tools/RenderTextureSaveToPNG/Editor.meta
vendored
Normal file
8
Assets/ThirdParty/Tools/RenderTextureSaveToPNG/Editor.meta
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c96d88b9c9c28634b9884fa74c19d963
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
54
Assets/ThirdParty/Tools/RenderTextureSaveToPNG/Editor/RenderTextureSaveToPNGEditor.cs
vendored
Normal file
54
Assets/ThirdParty/Tools/RenderTextureSaveToPNG/Editor/RenderTextureSaveToPNGEditor.cs
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
[CustomEditor(typeof(RenderTextureSaveToPNG))]
|
||||
public class RenderTextureSaveToPNGEditor : Editor
|
||||
{
|
||||
RenderTextureSaveToPNG inst;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
inst = (RenderTextureSaveToPNG)target;
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
base.OnInspectorGUI();
|
||||
|
||||
//
|
||||
if(GUILayout.Button("RenderTextureSaveToPNG", GUILayout.Height(50)))
|
||||
{
|
||||
SaveRenderToPng();
|
||||
}
|
||||
}
|
||||
|
||||
Texture2D SaveRenderToPng()
|
||||
{
|
||||
int width = inst.inputTex.width;
|
||||
int height = inst.inputTex.height;
|
||||
Texture2D tex2d = new Texture2D(width, height, TextureFormat.ARGB32, false);
|
||||
RenderTexture.active = inst.inputTex;
|
||||
tex2d.ReadPixels(new Rect(0, 0, width, height), 0, 0);
|
||||
|
||||
for(int y = 0; y < tex2d.height; ++y)
|
||||
{
|
||||
for (int x = 0; x < tex2d.width; ++x)
|
||||
{
|
||||
if(tex2d.GetPixel(x, y).grayscale > inst.maskSrength)
|
||||
{
|
||||
tex2d.SetPixel(x, y, Color.white);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tex2d.Apply();
|
||||
|
||||
File.WriteAllBytes(Application.dataPath + "/Materials/" + inst.inputTex.name + ".png", tex2d.EncodeToPNG());
|
||||
AssetDatabase.Refresh();
|
||||
|
||||
return tex2d;
|
||||
}
|
||||
}
|
||||
11
Assets/ThirdParty/Tools/RenderTextureSaveToPNG/Editor/RenderTextureSaveToPNGEditor.cs.meta
vendored
Normal file
11
Assets/ThirdParty/Tools/RenderTextureSaveToPNG/Editor/RenderTextureSaveToPNGEditor.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9198b13b7faa16441812599cf68e293b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
9
Assets/ThirdParty/Tools/RenderTextureSaveToPNG/RenderTextureSaveToPNG.cs
vendored
Normal file
9
Assets/ThirdParty/Tools/RenderTextureSaveToPNG/RenderTextureSaveToPNG.cs
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
|
||||
public class RenderTextureSaveToPNG : MonoBehaviour
|
||||
{
|
||||
public RenderTexture inputTex;
|
||||
public float maskSrength;
|
||||
}
|
||||
11
Assets/ThirdParty/Tools/RenderTextureSaveToPNG/RenderTextureSaveToPNG.cs.meta
vendored
Normal file
11
Assets/ThirdParty/Tools/RenderTextureSaveToPNG/RenderTextureSaveToPNG.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7dd021feda148b3428cae34737cce258
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user