You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.6 KiB
C#
61 lines
1.6 KiB
C#
using System;
|
|
|
|
namespace LanLib.Singleton
|
|
{
|
|
[Flags]
|
|
public enum SingletonDestroyCondition
|
|
{
|
|
/// <summary>
|
|
/// Dont destroy automatically.
|
|
/// </summary>
|
|
Never = 0,
|
|
|
|
/// <summary>
|
|
/// Destroy on scene unload.
|
|
/// </summary>
|
|
SceneUnload = 1 << 0,
|
|
|
|
/// <summary>
|
|
/// Destroy on script recompilation. [Default]
|
|
/// </summary>
|
|
ReloadDomain = 1 << 1,
|
|
|
|
/// <summary>
|
|
/// Destroy on application mode switch from play mode to editor mode.
|
|
/// </summary>
|
|
ExitPlay = 1 << 2,
|
|
|
|
/// <summary>
|
|
/// Destroy on application mode switch from editor mode to play mode.
|
|
/// </summary>
|
|
ExitEdit = 1 << 3,
|
|
}
|
|
|
|
[Flags]
|
|
public enum SingletonCreateCondition
|
|
{
|
|
/// <summary>
|
|
/// Dont instantiate automatically.
|
|
/// </summary>
|
|
LazyLoad = 0,
|
|
|
|
/// <summary>
|
|
/// Instantiate on domain reloads. More exactly, editor mode means script compiled mostly, while runtime mode means application launched.
|
|
/// </summary>
|
|
ReloadDomain = 1 << 0,
|
|
|
|
/// <summary>
|
|
/// Instantiate on enter play mode. Editor only.
|
|
/// </summary>
|
|
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;
|
|
}
|
|
} |