From 3cbe760b846ea5e883459e47f75a4d93964c78ef Mon Sep 17 00:00:00 2001 From: CroakFang <1605296300@qq.com> Date: Sat, 26 Aug 2023 02:46:28 +0800 Subject: [PATCH] Added eye texture cutting, bug fix --- Assets/Scripts/Exporters/TextureExporter.cs | 18 +++++++++++++++++- Assets/Scripts/UmaViewerBuilder.cs | 2 -- Assets/Scripts/UmaViewerMain.cs | 4 +++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/Assets/Scripts/Exporters/TextureExporter.cs b/Assets/Scripts/Exporters/TextureExporter.cs index 7b97def..ae29cfa 100644 --- a/Assets/Scripts/Exporters/TextureExporter.cs +++ b/Assets/Scripts/Exporters/TextureExporter.cs @@ -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); } diff --git a/Assets/Scripts/UmaViewerBuilder.cs b/Assets/Scripts/UmaViewerBuilder.cs index f0bd5b3..fdd99f4 100644 --- a/Assets/Scripts/UmaViewerBuilder.cs +++ b/Assets/Scripts/UmaViewerBuilder.cs @@ -40,8 +40,6 @@ public class UmaViewerBuilder : MonoBehaviour public GameObject LiveControllerPrefab; - private bool ShadersLoaded = false; - private void Awake() { Instance = this; diff --git a/Assets/Scripts/UmaViewerMain.cs b/Assets/Scripts/UmaViewerMain.cs index 05370fb..642abe0 100644 --- a/Assets/Scripts/UmaViewerMain.cs +++ b/Assets/Scripts/UmaViewerMain.cs @@ -196,7 +196,9 @@ public class UmaViewerMain : MonoBehaviour UI.LoadLivePanels(); loadingUI.LoadingProgressChange(-1, -1); - UmaAssetManager.LoadAssetBundle(AbList["shader"], true); //Load Shader First + //Load Shader First + var shaders = UmaAssetManager.LoadAssetBundle(AbList["shader"], true); + Builder.ShaderList = new List(shaders.LoadAllAssets()); } public void OpenUrl(string url)