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

ThemeEditor.cs 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using UnityEditor;
  2. using UnityEngine;
  3. using XCharts.Runtime;
  4. #if dUI_TextMeshPro
  5. using TMPro;
  6. #endif
  7. namespace XCharts.Editor
  8. {
  9. [CustomEditor(typeof(Theme))]
  10. public class ThemeEditor : UnityEditor.Editor
  11. {
  12. static class Styles
  13. {
  14. internal static GUIContent btnReset = new GUIContent("Reset to Default", "Reset to default theme");
  15. internal static GUIContent btnSyncFontToSubTheme = new GUIContent("Sync Font to Sub Theme", "Sync main theme font to sub theme font");
  16. internal static GUIContent btnSyncFontFromSetting = new GUIContent("Sync Font from Setting", "Sync main theme font and sub theme font from XCSetting font");
  17. }
  18. private Theme m_Theme;
  19. void OnEnable()
  20. {
  21. m_Theme = target as Theme;
  22. }
  23. public override void OnInspectorGUI()
  24. {
  25. base.OnInspectorGUI();
  26. if (GUILayout.Button(Styles.btnReset))
  27. {
  28. if (EditorUtility.DisplayDialog(Styles.btnReset.text, Styles.btnReset.tooltip, "Yes", "Cancel"))
  29. {
  30. m_Theme.ResetTheme();
  31. Debug.Log("XCharts: Reset Finish.");
  32. }
  33. }
  34. if (GUILayout.Button(Styles.btnSyncFontFromSetting))
  35. {
  36. if (EditorUtility.DisplayDialog(Styles.btnSyncFontFromSetting.text, Styles.btnSyncFontFromSetting.tooltip, "Yes", "Cancel"))
  37. {
  38. m_Theme.common.font = XCSettings.font;
  39. m_Theme.SyncFontToSubComponent();
  40. #if dUI_TextMeshPro
  41. m_Theme.common.tmpFont = XCSettings.tmpFont;
  42. m_Theme.SyncTMPFontToSubComponent();
  43. #endif
  44. Debug.Log("XCharts: Sync Finish.");
  45. }
  46. }
  47. if (GUILayout.Button(Styles.btnSyncFontToSubTheme))
  48. {
  49. if (EditorUtility.DisplayDialog(Styles.btnSyncFontToSubTheme.text, Styles.btnSyncFontToSubTheme.tooltip, "Yes", "Cancel"))
  50. {
  51. m_Theme.SyncFontToSubComponent();
  52. #if dUI_TextMeshPro
  53. m_Theme.SyncTMPFontToSubComponent();
  54. #endif
  55. Debug.Log("XCharts: Sync Finish.");
  56. }
  57. }
  58. }
  59. }
  60. }