diff --git a/Distribution/GameData/ConformalDecals/Assets/Sign-HighVoltage-2.png b/Distribution/GameData/ConformalDecals/Assets/Sign-HighVoltage-2.png new file mode 100644 index 0000000..19bccec Binary files /dev/null and b/Distribution/GameData/ConformalDecals/Assets/Sign-HighVoltage-2.png differ diff --git a/Distribution/GameData/ConformalDecals/Parts/decal-blank.cfg b/Distribution/GameData/ConformalDecals/Parts/decal-blank.cfg index fd0ddc2..ca47e70 100644 --- a/Distribution/GameData/ConformalDecals/Parts/decal-blank.cfg +++ b/Distribution/GameData/ConformalDecals/Parts/decal-blank.cfg @@ -47,22 +47,58 @@ PART decalFront = Decal-Front decalBack = Decal-Back - decalShader = ConformalDecals/Feature/Bumped useBaseNormal = false - TEXTURE - { - name = _Decal - textureURL = ConformalDecals/Assets/Tortilla-diffuse - isMain = true + + } + + MODULE { + name = ModuleB9PartSwitch + + SUBTYPE { + name = tortilla + + MODULE { + IDENTIFIER { + name = ModuleConformalDecal + } + DATA { + decalShader = ConformalDecals/Feature/Bumped + + TEXTURE { + name = _Decal + textureURL = ConformalDecals/Assets/Tortilla-diffuse + isMain = true + } + + TEXTURE + { + name = _BumpMap + textureURL = ConformalDecals/Assets/Tortilla-normal + isNormalMap = true + } + } + } } - TEXTURE - { - name = _BumpMap - textureURL = ConformalDecals/Assets/Tortilla-normal - isNormalMap = true + SUBTYPE { + name = Danger + + MODULE { + IDENTIFIER { + name = ModuleConformalDecal + } + DATA { + decalShader = ConformalDecals/Paint/Diffuse + useBaseNormal = true + TEXTURE { + name = _Decal + textureURL = ConformalDecals/Assets/Sign-HighVoltage-2 + isMain = true + } + } + } } } } diff --git a/Distribution/GameData/ConformalDecals/Plugins/ConformalDecals.dll b/Distribution/GameData/ConformalDecals/Plugins/ConformalDecals.dll index 27530f4..3612663 100644 Binary files a/Distribution/GameData/ConformalDecals/Plugins/ConformalDecals.dll and b/Distribution/GameData/ConformalDecals/Plugins/ConformalDecals.dll differ diff --git a/Source/ConformalDecals/MaterialModifiers/MaterialPropertyCollection.cs b/Source/ConformalDecals/MaterialModifiers/MaterialPropertyCollection.cs index 0b0397e..ed9f3ba 100644 --- a/Source/ConformalDecals/MaterialModifiers/MaterialPropertyCollection.cs +++ b/Source/ConformalDecals/MaterialModifiers/MaterialPropertyCollection.cs @@ -31,6 +31,12 @@ namespace ConformalDecals.MaterialModifiers { } public void AddProperty(MaterialProperty property) { + if (property == null) throw new ArgumentNullException("Tried to add a null property"); + if (_materialProperties == null || _textureMaterialProperties == null) { + Initialize(); + Debug.LogWarning("Tried to add a property to uninitialized property collection! correcting now."); + } + foreach (var p in _materialProperties) { if (p.PropertyName == property.PropertyName) { _materialProperties.Remove(property); @@ -53,8 +59,14 @@ namespace ConformalDecals.MaterialModifiers { } public void SetShader(string shaderName) { - if (_decalShader == null && string.IsNullOrEmpty(shaderName)) { - throw new FormatException("Shader name not provided"); + if (string.IsNullOrEmpty(shaderName)) { + if (_decalShader == null) { + Debug.Log("Using default decal shader"); + shaderName = "ConformalDecals/Paint/Diffuse"; + } + else { + return; + } } var shader = Shabby.Shabby.FindShader(shaderName); diff --git a/Source/ConformalDecals/ModuleConformalDecal.cs b/Source/ConformalDecals/ModuleConformalDecal.cs index 223b0fd..d503306 100644 --- a/Source/ConformalDecals/ModuleConformalDecal.cs +++ b/Source/ConformalDecals/ModuleConformalDecal.cs @@ -29,7 +29,7 @@ namespace ConformalDecals { [KSPField] public string decalBack = string.Empty; [KSPField] public string decalModel = string.Empty; [KSPField] public string decalProjector = string.Empty; - [KSPField] public string decalShader = string.Empty; + [KSPField] public string decalShader = "ConformalDecals/Paint/Diffuse"; [KSPField] public Transform decalFrontTransform; [KSPField] public Transform decalBackTransform; @@ -93,6 +93,7 @@ namespace ConformalDecals { } else { // materialProperties already exists, so make a copy + this.Log($"{materialProperties == null}"); materialProperties = ScriptableObject.Instantiate(materialProperties); } diff --git a/Source/ConformalDecals/ProjectionTarget.cs b/Source/ConformalDecals/ProjectionTarget.cs index 28e78d5..3cbbe31 100644 --- a/Source/ConformalDecals/ProjectionTarget.cs +++ b/Source/ConformalDecals/ProjectionTarget.cs @@ -1,5 +1,3 @@ -using System; -using ConformalDecals.MaterialModifiers; using ConformalDecals.Util; using UnityEngine; using UnityEngine.Rendering;