No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

EnumPopupSetting.cs 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System;
  2. using UnityEditor;
  3. namespace Unity.PlasticSCM.Editor.UI
  4. {
  5. internal static class EnumPopupSetting<E>
  6. {
  7. internal static E Load(
  8. string popupSettingName,
  9. E defaultValue)
  10. {
  11. string enumValue = EditorPrefs.GetString(
  12. GetSettingKey(popupSettingName));
  13. if (string.IsNullOrEmpty(enumValue))
  14. return defaultValue;
  15. return (E)Enum.Parse(typeof(E), enumValue);
  16. }
  17. internal static void Save(
  18. E selected,
  19. string popupSettingName)
  20. {
  21. EditorPrefs.SetString(
  22. GetSettingKey(popupSettingName),
  23. selected.ToString());
  24. }
  25. internal static void Clear(
  26. string popupSettingName)
  27. {
  28. EditorPrefs.DeleteKey(
  29. GetSettingKey(popupSettingName));
  30. }
  31. static string GetSettingKey(string popupSettingName)
  32. {
  33. return string.Format(
  34. popupSettingName, PlayerSettings.productGUID,
  35. SELECTED_ENUM_VALUE_KEY);
  36. }
  37. static string SELECTED_ENUM_VALUE_KEY = "SelectedEnumValue";
  38. }
  39. }