Destroy materials and properties when MPC is destroyed

feature-multiSDF
Andrew Cassidy 4 years ago
parent daf80b7f0f
commit 2174f2c07b

@ -99,6 +99,15 @@ namespace ConformalDecals.MaterialModifiers {
_materialProperties ??= new Dictionary<string, MaterialProperty>();
}
public void OnDestroy() {
if (_decalMaterial != null) Destroy(_decalMaterial);
if (_previewMaterial != null) Destroy(_previewMaterial);
foreach (var entry in _materialProperties) {
Destroy(entry.Value);
}
}
public void AddProperty(MaterialProperty property) {
if (property == null) throw new ArgumentNullException(nameof(property));

Loading…
Cancel
Save