using System; using UnityEngine; namespace UnityEditor.SettingsManagement { /// /// Register a static field of type IUserSetting with the UserSettingsProvider window. /// [AttributeUsage(AttributeTargets.Field)] public sealed class UserSettingAttribute : Attribute { string m_Category; GUIContent m_Title; bool m_VisibleInSettingsProvider; /// /// Settings that are automatically scraped from assemblies are displayed in groups, organized by category. /// /// /// The title of the group of settings that this setting will be shown under. /// public string category { get { return m_Category; } } /// /// The label to show for this setting. /// public GUIContent title { get { return m_Title; } } /// /// True if this field should be shown in the UserSettingsProvider interface, false if not. /// public bool visibleInSettingsProvider { get { return m_VisibleInSettingsProvider; } } /// /// Register a static field as a setting. Field must be of a type implementing IUserSetting. /// public UserSettingAttribute() { m_VisibleInSettingsProvider = false; } /// /// Register a static field as a setting and create an entry in the UI. Field must be of a type implementing IUserSetting. /// public UserSettingAttribute(string category, string title, string tooltip = null) { m_Category = category; m_Title = new GUIContent(title, tooltip); m_VisibleInSettingsProvider = true; } } /// /// Register a field with Settings, but do not automatically create a property field in the SettingsProvider. /// Unlike UserSettingAttribute, this attribute is valid for instance properties as well as static. These values /// will not be shown in the SettingsProvider, but will have their stored values cleared when "Reset All" is invoked. /// [AttributeUsage(AttributeTargets.Field)] public sealed class SettingsKeyAttribute : Attribute { string m_Key; SettingsScope m_Scope; /// /// The key for this value. /// public string key { get { return m_Key; } } /// /// Where this setting is serialized. /// public SettingsScope scope { get { return m_Scope; } } /// /// Register a field as a setting. This allows the UserSettingsProvider to reset it's value and display it's /// value in debugging modes. /// /// The setting key. /// The scope in which this setting is serialized. public SettingsKeyAttribute(string key, SettingsScope scope = SettingsScope.Project) { m_Key = key; m_Scope = scope; } } /// /// UserSettingBlock allows you add a section of settings to a category. /// [AttributeUsage(AttributeTargets.Method)] public sealed class UserSettingBlockAttribute : Attribute { string m_Category; /// /// Settings that are automatically scraped from assemblies are displayed in groups, organized by category. /// /// /// The title of the group of settings that this setting will be shown under. /// public string category { get { return m_Category; } } /// /// Register a static method for a callback in the UserSettingsProvider editor under a category. /// /// [UserSettingBlock("General")] /// static void GeneralSettings(string[] searchContext) {} /// /// /// The title of the group of settings that this setting will be shown under. public UserSettingBlockAttribute(string category) { m_Category = category; } } }