using UnityEditor;
using UnityEngine;
namespace Unity.Tutorials.Core.Editor
{
///
/// Wrapper for defining IET Preferences (User Settings) conveniently.
///
/// The Type of the value this Setting contains
public class UserSetting : BaseSetting
{
///
/// Constructs the setting.
///
/// Use Tr() in order to have localization support.
/// Key for the JSON file.
/// The value to initialize this new UserSetting to
/// Use Tr() in order to have localization support.
public UserSetting(string key, string name, T value, string tooltip = null)
: base(key, name, value, SettingsScope.User, tooltip)
{
}
}
///
/// Wrapper for defining IET Project Settings conveniently.
///
/// The Type of the value this Setting contains
///
/// If you wish to commit the changes to JSON immediately, use SetValue(value, saveProjectSettingsImmediately:true)
/// or FrameworkSettings.Instance.Save(), otherwise changes are committed only on application quit or assembly reload.
///
public class ProjectSetting : BaseSetting
{
///
/// Constructs the setting.
///
/// Key for EditorPrefs.
/// Use Tr() in order to have localization support.
/// The value to initialize this new ProjectSetting to
/// Use Tr() in order to have localization support.
public ProjectSetting(string key, string name, T value, string tooltip = null)
: base(key, name, value, SettingsScope.Project, tooltip)
{
}
}
///
/// Base class for implementing Tutorial Framework settings.
///
/// The Type of the value this Setting contains
public class BaseSetting : UnityEditor.SettingsManagement.UserSetting
{
///
/// Constructs the setting.
///
/// Key for EditorPrefs (User) or JSON file (Project).
/// Use Tr() in order to have localization support.
/// The value to initialize this new BaseSetting to
/// The SettingScope defining the scope of that new setting
/// Use Tr() in order to have localization support.
public BaseSetting(string key, string name, T value, SettingsScope scope, string tooltip = null)
: base(FrameworkSettings.Instance, key, value, scope)
{
Name = name;
Tooltip = tooltip;
}
///
/// Name of the setting.
///
public string Name { get; set; }
///
/// Tooltip for the setting.
///
public string Tooltip { get; set; }
///
/// Returns Name and Tooltip as GUIContent.
///
/// A GUIContent containing the Name and Tooltip of that setting
public GUIContent GetGuiContent() => new GUIContent(Name, Tooltip);
}
}