ViewGlobal.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. using FairyGUI;
  2. using System.Collections.Generic;
  3. using UI.Common;
  4. using UnityEngine;
  5. namespace GFGGame
  6. {
  7. public class ViewGlobal
  8. {
  9. private static UI_ComHolder comHolder;
  10. private static EffectUI _effectUI1;
  11. public static void CreatClickEffect()
  12. {
  13. if (comHolder == null)
  14. {
  15. comHolder = UI_ComHolder.Create();
  16. comHolder.target.touchable = false;
  17. ViewManager.AddChildToFloatLayer(comHolder.target);
  18. comHolder.target.SetPosition(-100, -100, 0);
  19. _effectUI1 = EffectUIPool.CreateEffectUI(comHolder.m_holder, "ui_dj", "DJ");
  20. GRoot.inst.onTouchBegin.Add(SetClickPos);
  21. }
  22. }
  23. private static void SetClickPos()
  24. {
  25. Vector2 pos = GRoot.inst.GlobalToLocal(Stage.inst.touchPosition);
  26. comHolder.m_holder.visible = false;
  27. comHolder.m_holder.visible = true;
  28. comHolder.target.SetPosition(pos.x, pos.y, 0);
  29. }
  30. /// <summary>
  31. /// 获取顶部摄像头的高度,减去一定的位移是因为设计图本身为顶部留出了一定的间隙
  32. /// </summary>
  33. /// <returns></returns>
  34. static float GetTopOffset()
  35. {
  36. int designOffset = (Screen.safeArea.height == Screen.height ? 0 : 90);
  37. return Screen.height - Screen.safeArea.height - Screen.safeArea.y - designOffset;
  38. }
  39. public static float GetRealTopOffset()
  40. {
  41. return Screen.height / UIContentScaler.scaleFactor - GetUIHeight();
  42. }
  43. /// <summary>
  44. /// 获取UI适配后的高度
  45. /// </summary>
  46. /// <returns></returns>
  47. public static float GetUIHeight()
  48. {
  49. return (Screen.height - GetTopOffset()) / UIContentScaler.scaleFactor;
  50. }
  51. public static List<Transform> FindAllGLoaderInTrans(Transform parent)
  52. {
  53. List<Transform> foundChildren = new List<Transform>();
  54. // 遍历当前父节点的所有子节点
  55. foreach (Transform child in parent)
  56. {
  57. // 检查子节点的名称是否匹配
  58. if (child.name == "GLoader" || child.name == "Shape")
  59. {
  60. // 将匹配的子节点添加到列表中
  61. foundChildren.Add(child);
  62. }
  63. // 递归调用,查找孙子节点
  64. foundChildren.AddRange(FindAllGLoaderInTrans(child));
  65. }
  66. return foundChildren;
  67. }
  68. private static List<string> fullScreenPicNames = new List<string>() { "loaBg", "mask" };
  69. private static List<string> notMoveUI = new List<string>() { "Top_img" };
  70. public static bool IsFullScreenPic(string name)
  71. {
  72. foreach(string s in fullScreenPicNames)
  73. {
  74. if(name == s)
  75. return true;
  76. }
  77. return false;
  78. }
  79. public static bool IsNotMoveUI(string name)
  80. {
  81. foreach (string s in notMoveUI)
  82. {
  83. if (s.Contains(name))
  84. return true;
  85. }
  86. return false;
  87. }
  88. }
  89. }