用于注册新的 SettingsProvider 的属性。使用此属性来修饰返回 SettingsProvider 实例的函数。如果函数返回 null,则设置窗口中不会出现任何 SettingsProvider。
using System.IO; using System.Linq; using UnityEditor;
class MyCustomSettingsProvider : SettingsProvider { const string k_MyCustomSettingsPath = "Resources/MyCustomSettings.asset"; public MyCustomSettingsProvider(string path, SettingsScope scope) : base(path, scope) {}
public static bool IsSettingsAvailable() { return File.Exists(k_MyCustomSettingsPath); }
[SettingsProvider] public static SettingsProvider CreateMyCustomSettingsProvider() { if (IsSettingsAvailable()) { return new MyCustomSettingsProvider("MyCustomSettings", SettingsScope.Project); }
// Settings Asset doesn't exist yet. No need to display anything in the Settings window. return null; } }
SettingsProviderAttribute | 创建一个用于注册新的 SettingsProvider 的 SettingsProviderAttribute。 |