Destroy materials and properties when MPC is destroyed

This commit is contained in:
Andrew Cassidy 2020-06-06 11:28:28 -07:00
parent 2592f15c4c
commit e6372b2703
No known key found for this signature in database
GPG Key ID: 963017B38FD477A1

View File

@ -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));