ViewGlobal.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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.safeArea.y) == Screen.height ? 0 : 80);
  37. int designOffset = 0;
  38. return Screen.height - Screen.safeArea.height - Screen.safeArea.y - designOffset;
  39. }
  40. /// <summary>
  41. /// 获取画布根据分辨率适配后的,顶部的实际高度
  42. /// </summary>
  43. /// <returns></returns>
  44. public static float GetRealTopOffset()
  45. {
  46. return Screen.height / UIContentScaler.scaleFactor - GetUIHeight();
  47. }
  48. /// <summary>
  49. /// 获取画布根据分辨率适配后的UI高度
  50. /// </summary>
  51. /// <returns></returns>
  52. public static float GetUIHeight()
  53. {
  54. return (Screen.height - GetTopOffset()) / UIContentScaler.scaleFactor;
  55. }
  56. public static List<Transform> FindAllGLoaderInTrans(Transform parent)
  57. {
  58. List<Transform> foundChildren = new List<Transform>();
  59. // 遍历当前父节点的所有子节点
  60. foreach (Transform child in parent)
  61. {
  62. // 检查子节点的名称是否匹配
  63. if (child.name == "GLoader" || child.name == "Shape")
  64. {
  65. // 将匹配的子节点添加到列表中
  66. foundChildren.Add(child);
  67. }
  68. // 递归调用,查找孙子节点
  69. foundChildren.AddRange(FindAllGLoaderInTrans(child));
  70. }
  71. return foundChildren;
  72. }
  73. private static List<string> fullScreenPicNames = new List<string>() { "loaBg", "mask" };
  74. private static List<string> notMoveUI = new List<string>() { "Top_img" };
  75. public static bool IsFullScreenPic(string name)
  76. {
  77. foreach (string s in fullScreenPicNames)
  78. {
  79. if (name == s)
  80. return true;
  81. }
  82. return false;
  83. }
  84. public static bool IsNotMoveUI(string name)
  85. {
  86. foreach (string s in notMoveUI)
  87. {
  88. if (s.Contains(name))
  89. return true;
  90. }
  91. return false;
  92. }
  93. }
  94. }