mirror of
https://github.com/drewcassidy/KSP-Conformal-Decals.git
synced 2024-09-01 18:23:54 +00:00
Clear targets on attach
This commit is contained in:
parent
7b9ed99325
commit
7406fa613b
Binary file not shown.
@ -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<Part> targetParts;
|
||||
if (projectMultiple) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user