I was following a Brackey’s tutorial, and he got rid of using ‘System.Collections;’ because it was useless. Is it really? What’s the purpose of it?
It’s a namespace that contains various collection types:
If you’re not using any types in a namespace, you can safely delete it’s using
declaration.
Visual Studio will indicate if you’re not using any types in a namespace by grey-ing out the using
declaration.
System.Collections may have been useless for that specific tutorial, but it’s not useless altogether.
The most likely reason you might want System.Collections is if you re using Unity coroutines. For actual collections people almost always use System.Collections.Generic instead.
Probably the primary reason why it’s added per default in Unity’s script templates is that it contains the IEnumerator interface, which is used when you implement coroutines - pretty common in Unity.
Like already mentioned, it also contains some other types, e.g. non-generic collection types, but they are not used as often since the better choice is generally a generic collection from System.Collections.Generic.