diff options
| author | Andrew Lee <alee14498@protonmail.com> | 2020-04-19 17:19:32 -0400 |
|---|---|---|
| committer | Andrew Lee <alee14498@protonmail.com> | 2020-04-19 17:19:32 -0400 |
| commit | c55fba8ab2a1c9d3df65eda4a5a1e957f4aa1f78 (patch) | |
| tree | ee4d51c7c1d633e11f46453ef1edd3c77c4ef9f7 /Library/PackageCache/com.unity.textmeshpro@2.0.1/Scripts/Editor/TMPro_EditorShaderUtilities.cs | |
| download | Project-Sandbox-c55fba8ab2a1c9d3df65eda4a5a1e957f4aa1f78.tar.gz Project-Sandbox-c55fba8ab2a1c9d3df65eda4a5a1e957f4aa1f78.tar.bz2 Project-Sandbox-c55fba8ab2a1c9d3df65eda4a5a1e957f4aa1f78.zip | |
Inital commit
Diffstat (limited to 'Library/PackageCache/com.unity.textmeshpro@2.0.1/Scripts/Editor/TMPro_EditorShaderUtilities.cs')
| -rw-r--r-- | Library/PackageCache/com.unity.textmeshpro@2.0.1/Scripts/Editor/TMPro_EditorShaderUtilities.cs | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/Library/PackageCache/com.unity.textmeshpro@2.0.1/Scripts/Editor/TMPro_EditorShaderUtilities.cs b/Library/PackageCache/com.unity.textmeshpro@2.0.1/Scripts/Editor/TMPro_EditorShaderUtilities.cs new file mode 100644 index 0000000..1633a68 --- /dev/null +++ b/Library/PackageCache/com.unity.textmeshpro@2.0.1/Scripts/Editor/TMPro_EditorShaderUtilities.cs @@ -0,0 +1,53 @@ +using UnityEngine;
+using UnityEditor;
+using System.Linq;
+using System.Collections;
+
+
+namespace TMPro.EditorUtilities
+{
+
+ public static class EditorShaderUtilities
+ {
+
+ /// <summary>
+ /// Copy Shader properties from source to destination material.
+ /// </summary>
+ /// <param name="source"></param>
+ /// <returns></returns>
+ public static void CopyMaterialProperties(Material source, Material destination)
+ {
+ MaterialProperty[] source_prop = MaterialEditor.GetMaterialProperties(new Material[] { source });
+
+ for (int i = 0; i < source_prop.Length; i++)
+ {
+ int property_ID = Shader.PropertyToID(source_prop[i].name);
+ if (destination.HasProperty(property_ID))
+ {
+ //Debug.Log(source_prop[i].name + " Type:" + ShaderUtil.GetPropertyType(source.shader, i));
+ switch (ShaderUtil.GetPropertyType(source.shader, i))
+ {
+ case ShaderUtil.ShaderPropertyType.Color:
+ destination.SetColor(property_ID, source.GetColor(property_ID));
+ break;
+ case ShaderUtil.ShaderPropertyType.Float:
+ destination.SetFloat(property_ID, source.GetFloat(property_ID));
+ break;
+ case ShaderUtil.ShaderPropertyType.Range:
+ destination.SetFloat(property_ID, source.GetFloat(property_ID));
+ break;
+ case ShaderUtil.ShaderPropertyType.TexEnv:
+ destination.SetTexture(property_ID, source.GetTexture(property_ID));
+ break;
+ case ShaderUtil.ShaderPropertyType.Vector:
+ destination.SetVector(property_ID, source.GetVector(property_ID));
+ break;
+ }
+ }
+ }
+
+ }
+
+ }
+
+}
\ No newline at end of file |
