Hash Set¶
The serializable hash set allows you to have the functionality of System.Collections.Generic.HashSet but also allows you to automatically serialize its values.
To create a serializable hash set, simply inherit from TSerializableHashSet<T>. For example, to create a hash set that uses string types:
[Serializable]
public class MyHashSet : TSerializableHashSet<string>
{ }
You can now create a hash set that automatically serializes its values and use it as:
public class MyComponent : MonoBehaviour
{
public MyHashSet hashSet = new MyHashSet();
private void Awake()
{
// Add element:
this.hashSet.Add("Hello World");
// Print if it can find the elements
Debug.Log(this.hashSet.Contains("Hello World"));
Debug.Log(this.hashSet.Contains("Foo"));
}
}