UITools.cs 900 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using System;
  2. using UnityEngine;
  3. public static class UITools
  4. {
  5. public static int ScreenHeight
  6. {
  7. get
  8. {
  9. return SingletonMono<UIController>.Instance.RootWidget.height;
  10. }
  11. }
  12. public static int ScreenWidth
  13. {
  14. get
  15. {
  16. return SingletonMono<UIController>.Instance.RootWidget.width;
  17. }
  18. }
  19. public static string SceneName
  20. {
  21. get
  22. {
  23. return LevelManager.SceneName;
  24. }
  25. }
  26. public static Vector2 ScreenPositionToLocalPosition(Vector2 screenPosition)
  27. {
  28. screenPosition.Scale(UITools.Multiplier);
  29. return screenPosition;
  30. }
  31. private static Vector2 Multiplier
  32. {
  33. get
  34. {
  35. return new Vector2((float)UITools.ScreenWidth / UITools.ScreenSize.x, (float)UITools.ScreenHeight / UITools.ScreenSize.y);
  36. }
  37. }
  38. private static Vector2 ScreenSize
  39. {
  40. get
  41. {
  42. return NGUITools.screenSize;
  43. }
  44. }
  45. private static string _sceneName;
  46. }