This commit is contained in:
2025-11-14 18:44:06 +08:00
parent 10156da245
commit 22e867d077
7013 changed files with 2572882 additions and 1804 deletions

View 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;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9198b13b7faa16441812599cf68e293b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: