设置相关功能脚本呢
This commit is contained in:
49
Assets/Scripts/Common/Services/Settings/Base/OptionBase.cs
Normal file
49
Assets/Scripts/Common/Services/Settings/Base/OptionBase.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
namespace NBF.Setting
|
||||
{
|
||||
public interface IOptionBase
|
||||
{
|
||||
string Name { get; }
|
||||
void Initialize();
|
||||
void Apply();
|
||||
}
|
||||
|
||||
public abstract class OptionBase : IOptionBase
|
||||
{
|
||||
protected string SaveKey => $"Setting_{Group}_{Name}";
|
||||
|
||||
public abstract string Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 所在组
|
||||
/// </summary>
|
||||
public abstract string Group { get; }
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
OnInitialize();
|
||||
Load();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载用户的设置
|
||||
/// </summary>
|
||||
public void Load()
|
||||
{
|
||||
OnLoad();
|
||||
}
|
||||
|
||||
public void Apply()
|
||||
{
|
||||
OnApply();
|
||||
}
|
||||
|
||||
protected abstract void OnInitialize();
|
||||
|
||||
|
||||
protected abstract void OnApply();
|
||||
|
||||
protected abstract void OnReset();
|
||||
|
||||
protected abstract void OnLoad();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user