void OnDestroy()
{
rendererWithMaterials.GetMaterials(allInstantiatedMaterials);
Debug.Log($"{allInstantiatedMaterials}");
foreach (Material material in allInstantiatedMaterials)
{
Debug.Log($"destroying {material}");
Destroy(material);
}
}
This method causes the error
ArgumentNullException: m
Parameter name: The result material list cannot be null.
UnityEngine.Renderer.GetMaterials (System.Collections.Generic.List`1[T] m) (at <25ce29052dfe4e49a635a42f7798806b>:0)
LightObjectVisuals.OnDestroy () (at Assets/Scripts/Effects/LightObjectVisuals.cs:38)
Line 38 is the GetMaterials one