x


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?

more ▼

asked Feb 01 '11 at 07:06 PM

Matthew A gravatar image

Matthew A
502 7 9 18

(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1359
x813
x764
x275
x6

asked: Feb 01 '11 at 07:06 PM

Seen: 1405 times

Last Updated: Feb 01 '11 at 07:06 PM