From 48819878dc7dd2c6a8972f0219c03b476f5c7ead Mon Sep 17 00:00:00 2001 From: drewcassidy Date: Sun, 28 Jun 2020 18:18:04 -0700 Subject: [PATCH] Add shader keyword support --- .../MaterialKeywordProperty.cs | 19 +++++++++++++++++++ .../MaterialTextureProperty.cs | 1 + 2 files changed, 20 insertions(+) create mode 100644 Source/ConformalDecals/MaterialProperties/MaterialKeywordProperty.cs diff --git a/Source/ConformalDecals/MaterialProperties/MaterialKeywordProperty.cs b/Source/ConformalDecals/MaterialProperties/MaterialKeywordProperty.cs new file mode 100644 index 0000000..c9ee240 --- /dev/null +++ b/Source/ConformalDecals/MaterialProperties/MaterialKeywordProperty.cs @@ -0,0 +1,19 @@ +using ConformalDecals.Util; +using UnityEngine; + +namespace ConformalDecals.MaterialProperties { + public class MaterialKeywordProperty : MaterialProperty { + [SerializeField] public bool value = true; + + public override void ParseNode(ConfigNode node) { + base.ParseNode(node); + + ParseUtil.ParseBoolIndirect(ref value, node, "value"); + } + + public override void Modify(Material material) { + if (value) material.EnableKeyword(_propertyName); + else material.DisableKeyword(_propertyName); + } + } +} \ No newline at end of file diff --git a/Source/ConformalDecals/MaterialProperties/MaterialTextureProperty.cs b/Source/ConformalDecals/MaterialProperties/MaterialTextureProperty.cs index fbbeacf..3299b0d 100644 --- a/Source/ConformalDecals/MaterialProperties/MaterialTextureProperty.cs +++ b/Source/ConformalDecals/MaterialProperties/MaterialTextureProperty.cs @@ -67,6 +67,7 @@ namespace ConformalDecals.MaterialProperties { material.SetTexture(_propertyID, _texture); material.SetTextureOffset(_propertyID, _textureOffset); material.SetTextureScale(_propertyID, _textureScale * _scale); + if (_propertyName != "_Decal") material.EnableKeyword("DECAL" + _propertyName.ToUpper()); } public void SetScale(Vector2 scale) {