mirror of
https://github.com/drewcassidy/KSP-Conformal-Decals.git
synced 2024-09-01 18:23:54 +00:00
better null checking
This commit is contained in:
parent
ece9d959fd
commit
d3388a4dad
@ -578,19 +578,10 @@ namespace ConformalDecals {
|
|||||||
public void Render(Camera camera) {
|
public void Render(Camera camera) {
|
||||||
if (!_isAttached) return;
|
if (!_isAttached) return;
|
||||||
|
|
||||||
try {
|
// render on each target object
|
||||||
// render on each target object
|
foreach (var target in _targets) {
|
||||||
foreach (var target in _targets) {
|
if (ReferenceEquals(target.target, null)) _targets.Remove(target);
|
||||||
target.Render(_decalMaterial, part.mpb, camera);
|
else target.Render(_decalMaterial, part.mpb, camera);
|
||||||
}
|
|
||||||
} catch (NullReferenceException) {
|
|
||||||
// catch any NREs and purge null transforms from the target list
|
|
||||||
// comparing Transform to null is expensive, but a try-catch block is much cheaper
|
|
||||||
foreach (var target in _targets) {
|
|
||||||
if (target.target == null) {
|
|
||||||
_targets.Remove(target);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user