- Home /
Destroy mesh / material after attaching to renderer
If I create a mesh or material using Instantiate, then assign it to a GameObject, do I then need to call Destroy on the mesh reference I have left, or on the mesh attached to the gameObject, or both? i.e.
Material m = Instantiate(material); go.renderer.material = m; // ? Destroy(m);
// later... when gameObject is destroyed? Destroy(go.renderer.material);
Is there any difference to this when using new to create the mesh / material instead?
Is there any difference if I assign it to sharedMaterial instead?
If doing this in the Editor, not while the application is playing should I call DestroyImmediate(m); once the material is assigned?
Comment