using System; namespace LanLib.Singleton { [Flags] public enum SingletonDestroyCondition { /// /// Dont destroy automatically. /// Never = 0, /// /// Destroy on scene unload. /// SceneUnload = 1 << 0, /// /// Destroy on script recompilation. [Default] /// ReloadDomain = 1 << 1, /// /// Destroy on application mode switch from play mode to editor mode. /// ExitPlay = 1 << 2, /// /// Destroy on application mode switch from editor mode to play mode. /// ExitEdit = 1 << 3, } [Flags] public enum SingletonCreateCondition { /// /// Dont instantiate automatically. /// LazyLoad = 0, /// /// Instantiate on domain reloads. More exactly, editor mode means script compiled mostly, while runtime mode means application launched. /// ReloadDomain = 1 << 0, /// /// Instantiate on enter play mode. Editor only. /// EnterPlay = 1 << 1, } public static class Extensions { public static bool Contains(this SingletonCreateCondition con, SingletonCreateCondition con2) => (con & con2) != 0; public static bool Contains(this SingletonDestroyCondition con, SingletonDestroyCondition con2) => (con & con2) != 0; } }