I have used a placement script to spawn multiple objects in my AR scene , and for interacting with them i have used Lean Touch i have used Lean selectable for selecting and interacting with a spawned object now i want to delete some spawned objects how can i achieve this? Somebody help…
2 Answers
2If you have a reference to the object you want to delete, you use the Destroy() method to get rid of it.
GameObject objToDestroy = <the object you want to delete>;
Destroy(objToDestroy);
If you have a reference to a component on the object you want to destroy, you can use .gameObject to get a reference to the GameObject that contains that component.
But I am not maintaining any reference to the spawned objects. I have multiple objects in my scene which is spawned using a custom script in that i don’t have any list or anything to store the spawned objects. But the selection and interactions are done using lean touch so how can i use the destroy method in it? Can i use it…?