using UnityEditor;
using UnityEngine;
namespace Unity.Tutorials.Core.Editor
{
///
/// Wrapper for defining IET Preferences (User Settings) conveniently.
///
///
public class UserSetting : BaseSetting
{
///
/// Constructs the setting.
///
/// Use Tr() in order to have localization support.
/// Key for the JSON file.
///
/// 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.
///
///
///
/// 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.
///
/// 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.
///
///
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.
///
///
/// 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.
///
///
public GUIContent GetGuiContent() => new GUIContent(Name, Tooltip);
}
}