暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

SpriteEditorWindowSettings.cs 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEditor;
  4. using UnityEngine;
  5. namespace UnityEditor.U2D.Sprites
  6. {
  7. internal class SpriteEditorWindowSettings : SettingsProvider
  8. {
  9. public const string kSettingsUniqueKey = "UnityEditor.U2D.Sprites/SpriteEditorWindow";
  10. public const string kShowRevertConfirmation = kSettingsUniqueKey + "RevertConfirmation";
  11. public const string kShowApplyConfirmation = kSettingsUniqueKey + "ApplyConfirmation";
  12. public static readonly GUIContent kShowRevertConfirmationLabel = EditorGUIUtility.TrTextContent("Show Revert Confirmation");
  13. public static readonly GUIContent kShowApplyConfirmationLabel = EditorGUIUtility.TrTextContent("Show Apply Confirmation");
  14. public SpriteEditorWindowSettings() : base("Preferences/2D/Sprite Editor Window", SettingsScope.User)
  15. {
  16. guiHandler = OnGUI;
  17. }
  18. [SettingsProvider]
  19. private static SettingsProvider CreateSettingsProvider()
  20. {
  21. return new SpriteEditorWindowSettings()
  22. {
  23. guiHandler = SettingsGUI
  24. };
  25. }
  26. private static void SettingsGUI(string searchContext)
  27. {
  28. showApplyConfirmation = EditorGUILayout.Toggle(kShowApplyConfirmationLabel, showApplyConfirmation);
  29. showRevertConfirmation = EditorGUILayout.Toggle(kShowRevertConfirmationLabel, showRevertConfirmation);
  30. }
  31. public static bool showRevertConfirmation
  32. {
  33. get { return EditorPrefs.GetBool(kShowRevertConfirmation, false); }
  34. set { EditorPrefs.SetBool(kShowRevertConfirmation, value); }
  35. }
  36. public static bool showApplyConfirmation
  37. {
  38. get { return EditorPrefs.GetBool(kShowApplyConfirmation, false); }
  39. set { EditorPrefs.SetBool(kShowApplyConfirmation, value); }
  40. }
  41. }
  42. }