- Home /
Remove specific instance of component if there are more of same type
Hi, is there a way to remove specific instance of component if there are more components of same type? Say, I have X component that is doing something, when it ends it should delete itself, normally I use
Destroy(GetComponent(typeof(X)));
but there is no quarranty that it will return this specific instance. Also
Destroy(this);
not works too.
Thanks in advance,
Paul
Comment
you'll need to iterate thru the components to find the one that you want to remove.
maybe you built a list when adding them...
@gjf Yes! Why i didn't think it out myself... anyway, convert this comment to answer and I will mark it as answered! Thanks!