x


Clearing a LineRenderer Whiteboard, so that you can start drawing again

This is related to my previous question, but maybe the method I asked of removing the component is not right.

Suppose you have a global var lineRenderer:LineRenderer as your Line Renderer variable. Each vertex is stored in linePoints - how do you wipe out all the lines, so that you can start over?

Destroy(lineRenderer); does not work. It will eventually give you an error when you try to initiate to draw new lines "Can't add component 'LineRenderer' to objName because such a component is already added to the game object! UnityEngine.GameObject:AddComponent(Type)"

more ▼

asked Dec 27 '10 at 07:19 AM

ina gravatar image

ina
3.3k 492 549 598

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

1 answer: sort voted first

I think you should keep the LineRender object, if possible. But if you use the Destroy you have to init it with a new fresh object, I think. I would look at LineRender object at see if there is a "Clear" function. I have searched a little but didnt find it, so perhaps the only way is to destroy the current instance and then initate a fresh new one?

more ▼

answered Jul 04 '11 at 07:20 PM

BerggreenDK gravatar image

BerggreenDK
2.4k 54 62 75

(comments are locked)
10|3000 characters needed characters left
Your answer
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:

x2083
x764
x303
x108
x77

asked: Dec 27 '10 at 07:19 AM

Seen: 1166 times

Last Updated: Jul 04 '11 at 07:20 PM