Added eye texture cutting, bug fix

This commit is contained in:
CroakFang
2023-08-26 02:46:28 +08:00
parent 316a78c944
commit 3cbe760b84
3 changed files with 20 additions and 4 deletions
+17 -1
View File
@@ -49,6 +49,7 @@ public class TextureExporter
if (mat_shader.GetPropertyType(i) == UnityEngine.Rendering.ShaderPropertyType.Texture)
{
Texture2D mat_texture = (Texture2D)mat.GetTexture(p_name);
if (mat_texture)
{
string tex_name = mat_texture.name;
@@ -59,8 +60,23 @@ public class TextureExporter
textureNames.Add(dpath);
}
if (!File.Exists(tex_path))
{
{
mat_texture = duplicateTexture(mat_texture);
if (tex_name.EndsWith("eye0"))
{
var clip_texture = duplicateTexture(mat_texture);
var pixels = clip_texture.GetPixels(0, 0, clip_texture.width / 4, clip_texture.height);
clip_texture.Resize(clip_texture.width / 4, clip_texture.height);
clip_texture.SetPixels(pixels);
byte[] clip = clip_texture.EncodeToPNG();
File.WriteAllBytes(tex_path, clip);
tex_path = savePath + tex_name + "_all" + ".png";
}
byte[] bytes = mat_texture.EncodeToPNG();
File.WriteAllBytes(tex_path, bytes);
}