diff --git a/GameData/ConformalDecals/Plugins/ConformalDecals.dll b/GameData/ConformalDecals/Plugins/ConformalDecals.dll index 98f7ec6..cb5e89a 100644 Binary files a/GameData/ConformalDecals/Plugins/ConformalDecals.dll and b/GameData/ConformalDecals/Plugins/ConformalDecals.dll differ diff --git a/Source/ConformalDecals/ModuleConformalDecal.cs b/Source/ConformalDecals/ModuleConformalDecal.cs index 291971b..dd32816 100644 --- a/Source/ConformalDecals/ModuleConformalDecal.cs +++ b/Source/ConformalDecals/ModuleConformalDecal.cs @@ -298,7 +298,7 @@ namespace ConformalDecals { if (this.part == eventPart) { OnAttach(); } - else if (projectMultiple) { + else if (_isAttached && projectMultiple) { UpdatePartTarget(eventPart, _boundsRenderer.bounds); // recursively call for child parts foreach (var child in eventPart.children) { @@ -312,7 +312,7 @@ namespace ConformalDecals { if (this.part == eventPart) { OnDetach(); } - else if (projectMultiple) { + else if (_isAttached && projectMultiple) { _targets.Remove(eventPart); // recursively call for child parts foreach (var child in eventPart.children) { @@ -327,7 +327,7 @@ namespace ConformalDecals { this.Log("Parent part about to be destroyed! Killing decal part."); part.Die(); } - else if (projectMultiple) { + else if (_isAttached && projectMultiple) { _targets.Remove(willDie); } } @@ -341,6 +341,7 @@ namespace ConformalDecals { } _isAttached = true; + _targets.Clear(); // hide model decalModelTransform.gameObject.SetActive(false); @@ -620,9 +621,13 @@ namespace ConformalDecals { /// Called when updating decal targets protected void UpdateTargets() { if (!_isAttached) return; - var projectionBounds = _boundsRenderer.bounds; + // disable all targets + foreach (var target in _targets.Values) { + target.enabled = false; + } + // collect list of potential targets IEnumerable targetParts; if (projectMultiple) { diff --git a/Source/ConformalDecals/ProjectionPartTarget.cs b/Source/ConformalDecals/ProjectionPartTarget.cs index 8dae1f9..19dacca 100644 --- a/Source/ConformalDecals/ProjectionPartTarget.cs +++ b/Source/ConformalDecals/ProjectionPartTarget.cs @@ -40,6 +40,8 @@ namespace ConformalDecals { } public void Render(Material decalMaterial, MaterialPropertyBlock partMPB, Camera camera) { + if (!enabled) return; + foreach (var target in meshTargets) { target.Render(decalMaterial, partMPB, camera); }