- Home /
Using HashSet in Unity
I want to use System.Collections.Generic.HashSet in my Unity project, but it won't compile. I Checked and HashSet is in system.core.dll, rather than mscorlib.dll or system.dll. Do we not have access to System.Core.dll?
I could always use a Dictionary and just set the values to true if they're in the set, and null or false if they're not, but a HashSet would be more ideal.
Answer by Ricardo · Feb 16, 2010 at 08:16 AM
As Soren mentions, you can't have that in Unity 2.x since the collection is only available in more recent versions of .Net. You are unlikely to get it before version 3, as it might mean breaking available games.
You may want to consider the C5 Generic Collection Library, a very well designed open source library containing more useful generic collections that you shake an iterator at (including HashSet and HashBag). Among many other great features, it's exceedingly well documented.
Answer by Sren Christiansen · Feb 16, 2010 at 08:05 AM
For now, Unity only support up to .NET 2.0 features. HashSet(T) is a .NET 3.5 feature.
Answer by Jaap Kreijkamp · Feb 16, 2010 at 07:53 AM
Which version of Unity? Unity iPhone doesn't support generics as it's an older version of Mono/.NET.
HashSet is a .NET 3.5 feature and unavailable in all Unity versions as of current to my knowledge.