DebuggerComponent.ScreenInformationWindow.cs 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. //------------------------------------------------------------
  2. // Game Framework v3.x
  3. // Copyright © 2013-2017 Jiang Yin. All rights reserved.
  4. // Homepage: http://gameframework.cn/
  5. // Feedback: mailto:jiangyin@gameframework.cn
  6. //------------------------------------------------------------
  7. using UnityEngine;
  8. namespace UnityGameFramework.Runtime
  9. {
  10. public partial class DebuggerComponent
  11. {
  12. private sealed class ScreenInformationWindow : ScrollableDebuggerWindowBase
  13. {
  14. protected override void OnDrawScrollableWindow()
  15. {
  16. GUILayout.Label("<b>Screen Information</b>");
  17. GUILayout.BeginVertical("box");
  18. {
  19. DrawItem("Current Resolution", GetResolutionString(Screen.currentResolution));
  20. DrawItem("Screen Width", string.Format("{0} px", Screen.width.ToString()));
  21. DrawItem("Screen Height", string.Format("{0} px", Screen.height.ToString()));
  22. DrawItem("Screen DPI", Screen.dpi.ToString("F2"));
  23. DrawItem("Screen Orientation", Screen.orientation.ToString());
  24. DrawItem("Is Full Screen", Screen.fullScreen.ToString());
  25. DrawItem("Sleep Timeout", GetSleepTimeoutDescription(Screen.sleepTimeout));
  26. DrawItem("Cursor Visible", Cursor.visible.ToString());
  27. DrawItem("Cursor Lock State", Cursor.lockState.ToString());
  28. DrawItem("Auto Landscape Left", Screen.autorotateToLandscapeLeft.ToString());
  29. DrawItem("Auto Landscape Right", Screen.autorotateToLandscapeRight.ToString());
  30. DrawItem("Auto Portrait", Screen.autorotateToPortrait.ToString());
  31. DrawItem("Auto Portrait Upside Down", Screen.autorotateToPortraitUpsideDown.ToString());
  32. DrawItem("Support Resolutions", GetResolutionsString(Screen.resolutions));
  33. }
  34. GUILayout.EndVertical();
  35. }
  36. private string GetSleepTimeoutDescription(int sleepTimeout)
  37. {
  38. if (sleepTimeout == SleepTimeout.NeverSleep)
  39. {
  40. return "Never Sleep";
  41. }
  42. if (sleepTimeout == SleepTimeout.SystemSetting)
  43. {
  44. return "System Setting";
  45. }
  46. return sleepTimeout.ToString();
  47. }
  48. private string GetResolutionString(Resolution resolution)
  49. {
  50. return string.Format("{0} x {1} @ {2}Hz", resolution.width.ToString(), resolution.height.ToString(), resolution.refreshRate.ToString());
  51. }
  52. private string GetResolutionsString(Resolution[] resolutions)
  53. {
  54. string[] resolutionStrings = new string[resolutions.Length];
  55. for (int i = 0; i < resolutions.Length; i++)
  56. {
  57. resolutionStrings[i] = GetResolutionString(resolutions[i]);
  58. }
  59. return string.Join("; ", resolutionStrings);
  60. }
  61. }
  62. }
  63. }