设置相关功能脚本呢
This commit is contained in:
34
Assets/Scripts/Common/Services/Settings/Base/OptionTable.cs
Normal file
34
Assets/Scripts/Common/Services/Settings/Base/OptionTable.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace NBF.Setting
|
||||
{
|
||||
public class OptionTable<T>
|
||||
{
|
||||
public struct OptionEntry
|
||||
{
|
||||
public string Name;
|
||||
public T Value;
|
||||
|
||||
public OptionEntry(string name, T value)
|
||||
{
|
||||
this.Name = name;
|
||||
this.Value = value;
|
||||
}
|
||||
}
|
||||
|
||||
List<OptionEntry> entries = new List<OptionEntry>();
|
||||
|
||||
public void Add(string name, T value)
|
||||
{
|
||||
entries.Add(new OptionEntry(name, value));
|
||||
}
|
||||
|
||||
public List<string> GetNames() => entries.Select(x => x.Name).ToList();
|
||||
public List<T> GetValues() => entries.Select(x => x.Value).ToList();
|
||||
|
||||
public T GetValue(int index) => entries[index].Value;
|
||||
|
||||
public string GetName(int index) => entries != null ? entries[index].Name : string.Empty;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user