用于注册多个 SettingsProvider 项的属性。使用此属性装饰返回 SettingsProvider 实例数组的函数。如果函数返回 null,则设置窗口中不会显示任何 SettingsProvider。
using System.IO; using System.Linq; using UnityEditor;
class XRSettings : SettingsProvider { const string k_XRSettingsFolder = "Assets/Editor/XRSettings"; public XRSettings(string path, SettingsScope scope = SettingsScope.Project) : base(path, scope) { }
[SettingsProviderGroup] public static SettingsProvider[] CreateProviders() { var files = Directory.GetFileSystemEntries(k_XRSettingsFolder, "*.json"); return files.Select(entry => { // First parameter is the path of the settings in the Settings window. return new XRSettings("Project/XRSettings/" + Path.GetFileNameWithoutExtension(entry)); }).ToArray(); } }
SettingsProviderGroupAttribute | 创建一个用于注册多个 SettingsProviders 的 SettingsProviderGroupAttribute。 |