W
W
WasTabon2020-12-08 17:38:17
Unity
WasTabon, 2020-12-08 17:38:17

How can I delete all objects in the scene with a tag?

In the code, 2 objects are created according to the prefab and when clicked, they should be deleted. Only 1 piece per click is deleted. I tried putting it in an array when creating an object, but it doesn't work.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
mistorp, 2020-12-08
@WasTabon

Try this:
GameObject object[] = GameObject.FindGameObjectsWithTag("here is your tag");
Destroy(object[]);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question