源战役客户端
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

233 řádky
8.3 KiB

před 4 týdny
  1. UIType = UIType or {
  2. Label = "Label", -- 文本 有滤镜 白色
  3. Label2 = "Label2", -- 文本 无滤镜 黑色
  4. Label3 = "Label3", -- 文本 无滤镜 浅棕色 文本左上角对齐
  5. Label4 = "Label4", -- 文本 无滤镜 有背景 白色
  6. Label5 = "Label5", -- 文本 无滤镜 HKYTW7 白色 文本居中对齐
  7. TextInput = "TextInput", -- 输入框
  8. Image = "Image", -- 图片容器
  9. Image2 = "Image2", -- 图片容器,锚点左上角
  10. Image3 = "Image3", -- 图片容器,锚点左上角
  11. BigButton1 = "BigButton1", -- 按钮
  12. BigButton2 = "BigButton2", -- 按钮
  13. BigButton3 = "BigButton3", -- 按钮
  14. SmallButton1 = "SmallButton1", -- 按钮
  15. SmallButton2 = "SmallButton2", -- 按钮
  16. SmallButton3 = "SmallButton3", -- 按钮
  17. RectButton1 = "RectButton1", --矩形按钮
  18. RectButton2 = "RectButton2", --矩形按钮
  19. RectButton3 = "RectButton3", --矩形按钮
  20. MiddleButton1 = "MiddleButton1", --按钮
  21. MiddleButton2 = "MiddleButton2", --按钮
  22. MiddleButton3 = "MiddleButton3", --按钮
  23. Loading = "Loading", --菊花loading
  24. ScrollView = "ScrollView", -- 滚动容器
  25. -- HScrollView = "HScrollView", --水平滚动容器
  26. Background = "Background", -- 窗口背景
  27. AddNumberComponent = "AddNumberComponent", -- 加减数量组件
  28. ProgressBar = "ProgressBar", -- 进度条
  29. ProgressBar2 = "ProgressBar2", -- 进度条
  30. SceneObj = "SceneObj", -- 默认形象的场景对象模板
  31. NameBoard = "NameBoard", -- 模型名字组件
  32. UIVerTabBtn = "UIVerTabBtn", -- verTabBar的按钮
  33. UIVerTabSubBtn = "UIVerTabSubBtn", -- verTabBar的下一级按钮
  34. UIHorTabBar = "UIHorTabBar", --横向bar
  35. UIHorTabBtn = "UIHorTabBtn", --横向bar的子按钮
  36. UIVerLabelBar = "UIVerLabelBar", --纵向bar的 无背景图 只有文字
  37. UIVerLabelBtn = "UIVerLabelBtn", --纵向bar的子按钮
  38. SpriteRenderer = "SpriteRenderer", -- SpriteRenderer 世界空间中的图片精灵组件
  39. EmptyObject = "EmptyObject", -- EmptyObject 2d空对象 一般作为代码创建的父容器使用
  40. EmptyObject2 = "EmptyObject2", -- EmptyObject2 2d空对象 一般作为代码创建的父容器使用 区别只是把锚点设置成了左上角
  41. CircleCd = "CircleCd", --圆形cd
  42. SquareCd = "SquareCd", --正方形cd,30 * 30
  43. FightingUp = "FightingUp", --战斗力提升
  44. AttrNumber = "AttrNumber", --属性增加
  45. RewardBox = "RewardBox", --奖励宝箱
  46. SceneDropObj = "SceneDropObj", --场景掉落
  47. ImageExtend = "ImageExtend", -- 图片容器
  48. TalkBoard = "TalkBoard", -- 角色说话
  49. -- UITalkBoard = "UITalkBoard", --UI模型说话
  50. ImageButton = "ImageButton", --隐藏按钮,用于新手引导
  51. BigBloodBar = "BigBloodBar", --大血条
  52. ToggleBtn = "ToggleBtn", --标签页
  53. Camera3D = "Camera3D", --3d摄像机
  54. TabButton = "TabButton",
  55. PopupComponent = "PopupComponent",
  56. NumberSliderComponent = "NumberSliderComponent",
  57. SceneCanvas = "SceneCanvas", --Scene层的canvas对象 比默认的性能更优
  58. FullWindowComponent = "FullWindowComponent", --全屏界面
  59. BarsItem = "BarsItem", --选项卡Item
  60. -------------------------
  61. WindowNew = "WindowNew", -- 全屏窗口,带tab
  62. WindowNew2 = "WindowNew2", -- 非全屏二级窗口,没有tab
  63. WindowNew4 = "WindowNew4", -- 伪全屏窗口,带tab 但是tab不带头像 具体参考副本大厅
  64. WindowNew5 = "WindowNew5", -- 伪全屏窗口,不带tab 具体参考多人副本
  65. WindowNew6 = "WindowNew6", -- 非全屏窗口,有tab
  66. WindowNew7 = "WindowNew7", -- 非全屏窗口,没有tab,底图文件夹样式
  67. WindowNew8 = "WindowNew8", -- 活动非全屏窗口,带tab 但是tab不带头像 具体参考充值
  68. UITabButton = "UITabButton", --界面右侧页签按钮
  69. UITabButton2 = "UITabButton2", --界面右侧页签按钮
  70. UITabButton3 = "UITabButton3", --界面右侧页签按钮
  71. UITabButton4 = "UITabButton4", --界面右侧页签按钮
  72. UITabButton5 = "UITabButton5", --界面右侧页签按钮
  73. UITabButton6 = "UITabButton6", --界面右侧页签按钮
  74. UITabButton8 = "UITabButton8", --活动伪全屏界面右侧页签按钮
  75. UITabButton9 = "UITabButton9", --特殊用,带图标的,如珍宝
  76. UIMoneyView = "UIMoneyView", --金币彩钻红钻添加
  77. Combox = "Combox", --通用下拉窗
  78. UIRoleMode = "UIRoleMode", --UI人物模型
  79. UI3dRtMode = "UI3dRtMode", --3d UI rendertexture 模式
  80. SceneJumpOneStepObj = "SceneJumpOneStepObj", --跳一跳跳台
  81. }
  82. --通用ui工厂
  83. UiFactory = UiFactory or BaseClass()
  84. local UiFactory = UiFactory
  85. UiFactory.preload_completed = false --预加载通用ui预制是否完成
  86. -- UiFactory.ui_assetBundle = nil -- 通用ui ab包
  87. UiFactory.ui_prefab_list = {} --通用ui 所有预制列表
  88. UiFactory.load_sequence_list = { --通用ui的加载顺序
  89. UIType.Label,
  90. UIType.Label2,
  91. UIType.Label3,
  92. UIType.Label4,
  93. UIType.Label5,
  94. UIType.TextInput,
  95. UIType.Image,
  96. UIType.Image2,
  97. UIType.Image3,
  98. UIType.BigButton1,
  99. UIType.BigButton2,
  100. UIType.BigButton3,
  101. UIType.SmallButton1,
  102. UIType.SmallButton2,
  103. UIType.SmallButton3,
  104. UIType.RectButton1,
  105. UIType.RectButton2,
  106. UIType.RectButton3,
  107. UIType.Loading,
  108. UIType.ScrollView,
  109. -- UIType.HScrollView,
  110. UIType.Background,
  111. UIType.AddNumberComponent,
  112. UIType.ProgressBar,
  113. UIType.ProgressBar2,
  114. UIType.SceneObj,
  115. UIType.NameBoard,
  116. UIType.UIVerTabBtn,
  117. UIType.UIVerTabSubBtn,
  118. UIType.UIHorTabBtn,
  119. UIType.UIHorTabBar,
  120. UIType.UIVerLabelBar,
  121. UIType.UIVerLabelBtn,
  122. UIType.SpriteRenderer,
  123. UIType.EmptyObject,
  124. UIType.EmptyObject2,
  125. UIType.Camera3D,
  126. UIType.CircleCd,
  127. UIType.SquareCd,
  128. UIType.FightingUp,
  129. UIType.AttrNumber,
  130. UIType.RewardBox,
  131. UIType.SceneDropObj,
  132. UIType.SceneJumpOneStepObj,
  133. UIType.ImageExtend,
  134. UIType.TalkBoard,
  135. -- UIType.UITalkBoard,
  136. UIType.ImageButton,
  137. UIType.BigBloodBar,
  138. UIType.ToggleBtn,
  139. UIType.TabButton,
  140. UIType.PopupComponent,
  141. UIType.NumberSliderComponent,
  142. UIType.SceneCanvas,
  143. -- UIType.FullWindowComponent,
  144. -- UIType.BarsItem,
  145. -------------------------
  146. UIType.WindowNew,
  147. UIType.WindowNew2,
  148. UIType.WindowNew4,
  149. UIType.WindowNew5,
  150. UIType.WindowNew6,
  151. UIType.WindowNew7,
  152. UIType.WindowNew8,
  153. UIType.UIMoneyView,
  154. UIType.Combox,
  155. -- UIType.UIRoleMode,
  156. }
  157. function UiFactory.StartPreload()
  158. if UiFactory.preload_completed == false then
  159. local function call_back(objs)
  160. -- UiFactory.ui_assetBundle = resMgr:GetAssetBundle("uiComponent")
  161. for i = 1,#UiFactory.load_sequence_list do
  162. UiFactory.ui_prefab_list[UiFactory.load_sequence_list[i]] = objs[i - 1]
  163. end
  164. local ui_prefab = UiFactory.ui_prefab_list[UIType.SceneCanvas]
  165. if ui_prefab then
  166. local transform = newObject(ui_prefab).transform
  167. local parent_go = GameObject.Find("Canvas")
  168. if parent_go then
  169. panelMgr:GetParent("Scene").gameObject:SetActive(false)
  170. transform:SetParent(parent_go.transform)
  171. SetLocalScale(transform)
  172. SetLocalPosition(transform)
  173. transform:SetAsFirstSibling()
  174. local canvas_com = transform:GetComponent("Canvas")
  175. if canvas_com then
  176. canvas_com.worldCamera = GameObject.Find("MainCamera"):GetComponent("Camera")
  177. end
  178. UiFactory.SceneCanvas = transform
  179. end
  180. end
  181. UiFactory.preload_completed = true --预加载完成
  182. GlobalEventSystem:Fire(EventName.GAME_UI_LOAD_COMPLETED)
  183. end
  184. LuaResManager:getInstance():loadPrefabs(UiFactory,"uiComponent",UiFactory.load_sequence_list, call_back, true, ASSETS_LEVEL.HIGHT)
  185. end
  186. local check_load = function()
  187. if not UiFactory.preload_completed then
  188. GameError.Instance:SendErrorToPHP("UiFactory.StartPreload 加载时间超过10秒没完成 预计加载失败")
  189. end
  190. end
  191. setTimeout(check_load,10)
  192. end
  193. function UiFactory.getPrefab(uiType)
  194. return UiFactory.ui_prefab_list[uiType]
  195. end
  196. function UiFactory.createChild(parent,uiType,uiName)
  197. -- if UiFactory.ui_assetBundle == nil then
  198. -- print("创建失败! 原因:通用ui AssetBundle 没有预加载成功")
  199. -- return
  200. -- end
  201. local ui_prefab = UiFactory.ui_prefab_list[uiType]
  202. if ui_prefab == nil then
  203. LogError("找不到uitype")
  204. return
  205. end
  206. local go = newObject(ui_prefab)
  207. if go then
  208. go.name = uiName or uiType
  209. if parent then
  210. go.transform:SetParent(parent)
  211. SetLocalScale(go.transform)
  212. SetLocalPosition(go.transform)
  213. -- go.transform.localScale = Vector3.one
  214. -- go.transform.localPosition = Vector3.zero
  215. end
  216. return go
  217. end
  218. end
  219. function UiFactory.GetSceneCanvas()
  220. return UiFactory.SceneCanvas or panelMgr:GetParent("Scene")
  221. end