- Home /
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)"
Answer by BerggreenDK · Jul 04, 2011 at 07:20 PM
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?
Your answer
Follow this Question
Related Questions
using Contains(gameObject) to find and destroy a gameObject from a list 2 Answers
Difference between capitalized component in AddComponent and Destroy 2 Answers
Cannot destroy Component while GameObject is being activated or deactivated 2 Answers
How to get a component from an object and add it to another? (Copy components at runtime) 12 Answers
Destroying a LineRenderer component and then adding it again at runtime 4 Answers