GameViewSizeHelper.cs 496 B

12345678910111213141516171819202122232425262728
  1. using UnityEngine;
  2. #if UNITY_EDITOR
  3. using UnityEditor;
  4. #endif
  5. namespace AdaptUI
  6. {
  7. public static class GameViewSizeHelper
  8. {
  9. public static Vector2 GetGameViewSize()
  10. {
  11. #if UNITY_EDITOR
  12. return GetGameViewSize_Editor();
  13. #else
  14. return new Vector2(Screen.width, Screen.height);
  15. #endif
  16. }
  17. #if UNITY_EDITOR
  18. public static Vector2 GetGameViewSize_Editor()
  19. {
  20. return Handles.GetMainGameViewSize();
  21. }
  22. #endif
  23. }
  24. }