using System; using UnityEngine; namespace UnityEditor.SettingsManagement { /// /// A custom attribute for registering a static field of type for the window. /// [AttributeUsage(AttributeTargets.Field)] public sealed class UserSettingAttribute : Attribute { string m_Category; GUIContent m_Title; bool m_VisibleInSettingsProvider; /// /// Gets the name of the group (category) to assign this settings value to. /// When Unity finds settings values in assemblies, it displays them in groups, organized by category. /// /// The group or category where this setting appears in the UI. public string category { get { return m_Category; } } /// /// Gets the label to show for this setting. /// /// The label that appears beside this setting in the UI. public GUIContent title { get { return m_Title; } } /// /// True to show this field in the interface; false if not. /// public bool visibleInSettingsProvider { get { return m_VisibleInSettingsProvider; } } /// /// Registers a static field as a setting. Fields must be of a type that implements . /// public UserSettingAttribute() { m_VisibleInSettingsProvider = false; } /// /// Registers a static field as a setting and creates an entry in the UI. The field must be of a type that implements . /// /// The category to assign this setting to. /// The display text for this setting in the UI. /// Optional. The tooltip for this setting. public UserSettingAttribute(string category, string title, string tooltip = null) { m_Category = category; m_Title = new GUIContent(title, tooltip); m_VisibleInSettingsProvider = true; } } /// /// A custom attribute for registering a field with , but without automatically creating /// a property field in the . /// Unlike , this attribute is valid for instance properties as well as static. These values /// don't appear in the SettingsProvider. Unity clears their stored values when "Reset All" is invoked. /// [AttributeUsage(AttributeTargets.Field)] public sealed class SettingsKeyAttribute : Attribute { string m_Key; SettingsScope m_Scope; /// /// Gets the key for this value. /// /// The key used to identify this settings value from the repository. public string key { get { return m_Key; } } /// /// Gets the location where this setting is serialized. /// /// /// Indicates whether this is a setting /// or a preference. /// public SettingsScope scope { get { return m_Scope; } } /// /// Registers a field as a setting. This allows the to reset its value and display it /// in debugging modes. /// /// The key for this setting. /// The scope in which this setting is serialized. public SettingsKeyAttribute(string key, SettingsScope scope = SettingsScope.Project) { m_Key = key; m_Scope = scope; } } /// /// A custom attribute for adding a section of settings to a category. /// [AttributeUsage(AttributeTargets.Method)] public sealed class UserSettingBlockAttribute : Attribute { string m_Category; /// /// Returns the title for the settings group. /// When Unity finds settings values in assemblies, it displays them in groups, organized by category. /// /// The group or category where this setting appears in the UI. public string category { get { return m_Category; } } /// /// Registers a static method for a callback in the Editor window under a category. /// /// /// Specify the title of the group of settings under which this setting appears in the UI. public UserSettingBlockAttribute(string category) { m_Category = category; } } }