///<summary> OnEnable method to associate Multiton to their Instance.</summary> protected virtual void OnEnable() { bool __typeExists = InstancesDictionary.TryGetValue(typeof(T), out object instances); if (!__typeExists) { instances = new List <T>(Length); InstancesDictionary.Add(typeof(T), instances); } ((List <T>)instances)?.Add((T)this); }
///<summary> OnDisable method to clear Multiton association.</summary> protected virtual void OnDisable() { InstancesDictionary.TryGetValue(typeof(T), out object __instances); ((List <T>)__instances)?.Remove((T)this); }