From 8b384dffa0d9c63c7a657c6e567c2ddefbf046cd Mon Sep 17 00:00:00 2001 From: chai Date: Sun, 11 Oct 2020 20:00:58 +0800 Subject: +Saionji show off scene --- .../Runtime/PreShaderPropExporter.cs | 64 ++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 Assets/ThirdParty/VRM/VRMShaders/ShaderProperty/Runtime/PreShaderPropExporter.cs (limited to 'Assets/ThirdParty/VRM/VRMShaders/ShaderProperty/Runtime/PreShaderPropExporter.cs') diff --git a/Assets/ThirdParty/VRM/VRMShaders/ShaderProperty/Runtime/PreShaderPropExporter.cs b/Assets/ThirdParty/VRM/VRMShaders/ShaderProperty/Runtime/PreShaderPropExporter.cs new file mode 100644 index 00000000..bdc6b49d --- /dev/null +++ b/Assets/ThirdParty/VRM/VRMShaders/ShaderProperty/Runtime/PreShaderPropExporter.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; +using UnityEngine; +#if UNITY_EDITOR +using UnityEditor; +#endif + + +namespace UniGLTF.ShaderPropExporter +{ + public class PreExportShadersAttribute : Attribute { } + public class PreExportShaderAttribute : Attribute { } + + public struct SupportedShader + { + public string TargetFolder; + public string ShaderName; + + public SupportedShader(string targetFolder, string shaderName) + { + TargetFolder = targetFolder; + ShaderName = shaderName; + } + } + + public static partial class PreShaderPropExporter + { + static Dictionary m_shaderPropMap; + + public static ShaderProps GetPropsForSupportedShader(string shaderName) + { + if (m_shaderPropMap == null) + { + m_shaderPropMap = new Dictionary(); + foreach (var prop in typeof(PreShaderPropExporter).GetProperties(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)) + { + if (prop.GetCustomAttributes(typeof(PreExportShaderAttribute), true).Any()) + { + var kv = (KeyValuePair)prop.GetValue(null, null); + m_shaderPropMap.Add(kv.Key, kv.Value); + } + } + } + + ShaderProps props; + if (m_shaderPropMap.TryGetValue(shaderName, out props)) + { + return props; + } + +#if UNITY_EDITOR + // fallback + Debug.LogWarningFormat("{0} is not predefined shader. Use ShaderUtil", shaderName); + var shader = Shader.Find(shaderName); + return ShaderProps.FromShader(shader); +#else + return null; +#endif + } + } +} -- cgit v1.1-26-g67d0