123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- using System;
- using UnityEngine;
- namespace UnityEditor.SettingsManagement
- {
- /// <summary>
- /// Register a static field of type IUserSetting with the UserSettingsProvider window.
- /// </summary>
- [AttributeUsage(AttributeTargets.Field)]
- public sealed class UserSettingAttribute : Attribute
- {
- string m_Category;
- GUIContent m_Title;
- bool m_VisibleInSettingsProvider;
- /// <summary>
- /// Settings that are automatically scraped from assemblies are displayed in groups, organized by category.
- /// </summary>
- /// <value>
- /// The title of the group of settings that this setting will be shown under.
- /// </value>
- public string category
- {
- get { return m_Category; }
- }
- /// <value>
- /// The label to show for this setting.
- /// </value>
- public GUIContent title
- {
- get { return m_Title; }
- }
- /// <value>
- /// True if this field should be shown in the UserSettingsProvider interface, false if not.
- /// </value>
- public bool visibleInSettingsProvider
- {
- get { return m_VisibleInSettingsProvider; }
- }
- /// <summary>
- /// Register a static field as a setting. Field must be of a type implementing IUserSetting.
- /// </summary>
- public UserSettingAttribute()
- {
- m_VisibleInSettingsProvider = false;
- }
- /// <summary>
- /// Register a static field as a setting and create an entry in the UI. Field must be of a type implementing IUserSetting.
- /// </summary>
- public UserSettingAttribute(string category, string title, string tooltip = null)
- {
- m_Category = category;
- m_Title = new GUIContent(title, tooltip);
- m_VisibleInSettingsProvider = true;
- }
- }
- /// <summary>
- /// 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.
- /// </summary>
- [AttributeUsage(AttributeTargets.Field)]
- public sealed class SettingsKeyAttribute : Attribute
- {
- string m_Key;
- SettingsScope m_Scope;
- /// <value>
- /// The key for this value.
- /// </value>
- public string key
- {
- get { return m_Key; }
- }
- /// <value>
- /// Where this setting is serialized.
- /// </value>
- public SettingsScope scope
- {
- get { return m_Scope; }
- }
- /// <summary>
- /// Register a field as a setting. This allows the UserSettingsProvider to reset it's value and display it's
- /// value in debugging modes.
- /// </summary>
- /// <param name="key">The setting key.</param>
- /// <param name="scope">The scope in which this setting is serialized.</param>
- public SettingsKeyAttribute(string key, SettingsScope scope = SettingsScope.Project)
- {
- m_Key = key;
- m_Scope = scope;
- }
- }
- /// <summary>
- /// UserSettingBlock allows you add a section of settings to a category.
- /// </summary>
- [AttributeUsage(AttributeTargets.Method)]
- public sealed class UserSettingBlockAttribute : Attribute
- {
- string m_Category;
- /// <summary>
- /// Settings that are automatically scraped from assemblies are displayed in groups, organized by category.
- /// </summary>
- /// <value>
- /// The title of the group of settings that this setting will be shown under.
- /// </value>
- public string category
- {
- get { return m_Category; }
- }
- /// <summary>
- /// Register a static method for a callback in the UserSettingsProvider editor under a category.
- /// <code>
- /// [UserSettingBlock("General")]
- /// static void GeneralSettings(string[] searchContext) {}
- /// </code>
- /// </summary>
- /// <param name="category">The title of the group of settings that this setting will be shown under.</param>
- public UserSettingBlockAttribute(string category)
- {
- m_Category = category;
- }
- }
- }
|