|
UIType = UIType or {
|
|
Label = "Label", -- 文本 有滤镜 白色
|
|
Label2 = "Label2", -- 文本 无滤镜 黑色
|
|
Label3 = "Label3", -- 文本 无滤镜 浅棕色 文本左上角对齐
|
|
Label4 = "Label4", -- 文本 无滤镜 有背景 白色
|
|
Label5 = "Label5", -- 文本 无滤镜 HKYTW7 白色 文本居中对齐
|
|
TextInput = "TextInput", -- 输入框
|
|
Image = "Image", -- 图片容器
|
|
Image2 = "Image2", -- 图片容器,锚点左上角
|
|
Image3 = "Image3", -- 图片容器,锚点左上角
|
|
BigButton1 = "BigButton1", -- 按钮
|
|
BigButton2 = "BigButton2", -- 按钮
|
|
BigButton3 = "BigButton3", -- 按钮
|
|
SmallButton1 = "SmallButton1", -- 按钮
|
|
SmallButton2 = "SmallButton2", -- 按钮
|
|
SmallButton3 = "SmallButton3", -- 按钮
|
|
RectButton1 = "RectButton1", --矩形按钮
|
|
RectButton2 = "RectButton2", --矩形按钮
|
|
RectButton3 = "RectButton3", --矩形按钮
|
|
MiddleButton1 = "MiddleButton1", --按钮
|
|
MiddleButton2 = "MiddleButton2", --按钮
|
|
MiddleButton3 = "MiddleButton3", --按钮
|
|
Loading = "Loading", --菊花loading
|
|
ScrollView = "ScrollView", -- 滚动容器
|
|
-- HScrollView = "HScrollView", --水平滚动容器
|
|
Background = "Background", -- 窗口背景
|
|
AddNumberComponent = "AddNumberComponent", -- 加减数量组件
|
|
ProgressBar = "ProgressBar", -- 进度条
|
|
ProgressBar2 = "ProgressBar2", -- 进度条
|
|
SceneObj = "SceneObj", -- 默认形象的场景对象模板
|
|
NameBoard = "NameBoard", -- 模型名字组件
|
|
UIVerTabBtn = "UIVerTabBtn", -- verTabBar的按钮
|
|
UIVerTabSubBtn = "UIVerTabSubBtn", -- verTabBar的下一级按钮
|
|
UIHorTabBar = "UIHorTabBar", --横向bar
|
|
UIHorTabBtn = "UIHorTabBtn", --横向bar的子按钮
|
|
UIVerLabelBar = "UIVerLabelBar", --纵向bar的 无背景图 只有文字
|
|
UIVerLabelBtn = "UIVerLabelBtn", --纵向bar的子按钮
|
|
SpriteRenderer = "SpriteRenderer", -- SpriteRenderer 世界空间中的图片精灵组件
|
|
EmptyObject = "EmptyObject", -- EmptyObject 2d空对象 一般作为代码创建的父容器使用
|
|
EmptyObject2 = "EmptyObject2", -- EmptyObject2 2d空对象 一般作为代码创建的父容器使用 区别只是把锚点设置成了左上角
|
|
CircleCd = "CircleCd", --圆形cd
|
|
SquareCd = "SquareCd", --正方形cd,30 * 30
|
|
FightingUp = "FightingUp", --战斗力提升
|
|
AttrNumber = "AttrNumber", --属性增加
|
|
RewardBox = "RewardBox", --奖励宝箱
|
|
SceneDropObj = "SceneDropObj", --场景掉落
|
|
ImageExtend = "ImageExtend", -- 图片容器
|
|
TalkBoard = "TalkBoard", -- 角色说话
|
|
-- UITalkBoard = "UITalkBoard", --UI模型说话
|
|
ImageButton = "ImageButton", --隐藏按钮,用于新手引导
|
|
BigBloodBar = "BigBloodBar", --大血条
|
|
ToggleBtn = "ToggleBtn", --标签页
|
|
Camera3D = "Camera3D", --3d摄像机
|
|
TabButton = "TabButton",
|
|
PopupComponent = "PopupComponent",
|
|
NumberSliderComponent = "NumberSliderComponent",
|
|
SceneCanvas = "SceneCanvas", --Scene层的canvas对象 比默认的性能更优
|
|
FullWindowComponent = "FullWindowComponent", --全屏界面
|
|
BarsItem = "BarsItem", --选项卡Item
|
|
|
|
-------------------------
|
|
WindowNew = "WindowNew", -- 全屏窗口,带tab
|
|
WindowNew2 = "WindowNew2", -- 非全屏二级窗口,没有tab
|
|
WindowNew4 = "WindowNew4", -- 伪全屏窗口,带tab 但是tab不带头像 具体参考副本大厅
|
|
WindowNew5 = "WindowNew5", -- 伪全屏窗口,不带tab 具体参考多人副本
|
|
WindowNew6 = "WindowNew6", -- 非全屏窗口,有tab
|
|
WindowNew7 = "WindowNew7", -- 非全屏窗口,没有tab,底图文件夹样式
|
|
WindowNew8 = "WindowNew8", -- 活动非全屏窗口,带tab 但是tab不带头像 具体参考充值
|
|
|
|
UITabButton = "UITabButton", --界面右侧页签按钮
|
|
UITabButton2 = "UITabButton2", --界面右侧页签按钮
|
|
UITabButton3 = "UITabButton3", --界面右侧页签按钮
|
|
UITabButton4 = "UITabButton4", --界面右侧页签按钮
|
|
UITabButton5 = "UITabButton5", --界面右侧页签按钮
|
|
UITabButton6 = "UITabButton6", --界面右侧页签按钮
|
|
UITabButton8 = "UITabButton8", --活动伪全屏界面右侧页签按钮
|
|
UITabButton9 = "UITabButton9", --特殊用,带图标的,如珍宝
|
|
UIMoneyView = "UIMoneyView", --金币彩钻红钻添加
|
|
Combox = "Combox", --通用下拉窗
|
|
|
|
UIRoleMode = "UIRoleMode", --UI人物模型
|
|
UI3dRtMode = "UI3dRtMode", --3d UI rendertexture 模式
|
|
|
|
SceneJumpOneStepObj = "SceneJumpOneStepObj", --跳一跳跳台
|
|
}
|
|
|
|
|
|
--通用ui工厂
|
|
UiFactory = UiFactory or BaseClass()
|
|
local UiFactory = UiFactory
|
|
UiFactory.preload_completed = false --预加载通用ui预制是否完成
|
|
-- UiFactory.ui_assetBundle = nil -- 通用ui ab包
|
|
UiFactory.ui_prefab_list = {} --通用ui 所有预制列表
|
|
UiFactory.load_sequence_list = { --通用ui的加载顺序
|
|
UIType.Label,
|
|
UIType.Label2,
|
|
UIType.Label3,
|
|
UIType.Label4,
|
|
UIType.Label5,
|
|
UIType.TextInput,
|
|
UIType.Image,
|
|
UIType.Image2,
|
|
UIType.Image3,
|
|
UIType.BigButton1,
|
|
UIType.BigButton2,
|
|
UIType.BigButton3,
|
|
UIType.SmallButton1,
|
|
UIType.SmallButton2,
|
|
UIType.SmallButton3,
|
|
UIType.RectButton1,
|
|
UIType.RectButton2,
|
|
UIType.RectButton3,
|
|
UIType.Loading,
|
|
UIType.ScrollView,
|
|
-- UIType.HScrollView,
|
|
UIType.Background,
|
|
UIType.AddNumberComponent,
|
|
UIType.ProgressBar,
|
|
UIType.ProgressBar2,
|
|
UIType.SceneObj,
|
|
UIType.NameBoard,
|
|
UIType.UIVerTabBtn,
|
|
UIType.UIVerTabSubBtn,
|
|
UIType.UIHorTabBtn,
|
|
UIType.UIHorTabBar,
|
|
UIType.UIVerLabelBar,
|
|
UIType.UIVerLabelBtn,
|
|
UIType.SpriteRenderer,
|
|
UIType.EmptyObject,
|
|
UIType.EmptyObject2,
|
|
UIType.Camera3D,
|
|
UIType.CircleCd,
|
|
UIType.SquareCd,
|
|
UIType.FightingUp,
|
|
UIType.AttrNumber,
|
|
UIType.RewardBox,
|
|
UIType.SceneDropObj,
|
|
UIType.SceneJumpOneStepObj,
|
|
UIType.ImageExtend,
|
|
UIType.TalkBoard,
|
|
-- UIType.UITalkBoard,
|
|
UIType.ImageButton,
|
|
UIType.BigBloodBar,
|
|
UIType.ToggleBtn,
|
|
UIType.TabButton,
|
|
UIType.PopupComponent,
|
|
UIType.NumberSliderComponent,
|
|
UIType.SceneCanvas,
|
|
-- UIType.FullWindowComponent,
|
|
-- UIType.BarsItem,
|
|
|
|
-------------------------
|
|
UIType.WindowNew,
|
|
UIType.WindowNew2,
|
|
UIType.WindowNew4,
|
|
UIType.WindowNew5,
|
|
UIType.WindowNew6,
|
|
UIType.WindowNew7,
|
|
UIType.WindowNew8,
|
|
UIType.UIMoneyView,
|
|
UIType.Combox,
|
|
-- UIType.UIRoleMode,
|
|
}
|
|
function UiFactory.StartPreload()
|
|
if UiFactory.preload_completed == false then
|
|
local function call_back(objs)
|
|
-- UiFactory.ui_assetBundle = resMgr:GetAssetBundle("uiComponent")
|
|
for i = 1,#UiFactory.load_sequence_list do
|
|
UiFactory.ui_prefab_list[UiFactory.load_sequence_list[i]] = objs[i - 1]
|
|
end
|
|
|
|
local ui_prefab = UiFactory.ui_prefab_list[UIType.SceneCanvas]
|
|
if ui_prefab then
|
|
local transform = newObject(ui_prefab).transform
|
|
local parent_go = GameObject.Find("Canvas")
|
|
if parent_go then
|
|
panelMgr:GetParent("Scene").gameObject:SetActive(false)
|
|
transform:SetParent(parent_go.transform)
|
|
SetLocalScale(transform)
|
|
SetLocalPosition(transform)
|
|
transform:SetAsFirstSibling()
|
|
|
|
local canvas_com = transform:GetComponent("Canvas")
|
|
if canvas_com then
|
|
canvas_com.worldCamera = GameObject.Find("MainCamera"):GetComponent("Camera")
|
|
end
|
|
UiFactory.SceneCanvas = transform
|
|
end
|
|
end
|
|
|
|
UiFactory.preload_completed = true --预加载完成
|
|
GlobalEventSystem:Fire(EventName.GAME_UI_LOAD_COMPLETED)
|
|
end
|
|
LuaResManager:getInstance():loadPrefabs(UiFactory,"uiComponent",UiFactory.load_sequence_list, call_back, true, ASSETS_LEVEL.HIGHT)
|
|
end
|
|
local check_load = function()
|
|
if not UiFactory.preload_completed then
|
|
GameError.Instance:SendErrorToPHP("UiFactory.StartPreload 加载时间超过10秒没完成 预计加载失败")
|
|
end
|
|
end
|
|
setTimeout(check_load,10)
|
|
end
|
|
|
|
function UiFactory.getPrefab(uiType)
|
|
return UiFactory.ui_prefab_list[uiType]
|
|
end
|
|
|
|
function UiFactory.createChild(parent,uiType,uiName)
|
|
-- if UiFactory.ui_assetBundle == nil then
|
|
-- print("创建失败! 原因:通用ui AssetBundle 没有预加载成功")
|
|
-- return
|
|
-- end
|
|
local ui_prefab = UiFactory.ui_prefab_list[uiType]
|
|
if ui_prefab == nil then
|
|
LogError("找不到uitype")
|
|
return
|
|
end
|
|
local go = newObject(ui_prefab)
|
|
if go then
|
|
go.name = uiName or uiType
|
|
if parent then
|
|
go.transform:SetParent(parent)
|
|
SetLocalScale(go.transform)
|
|
SetLocalPosition(go.transform)
|
|
-- go.transform.localScale = Vector3.one
|
|
-- go.transform.localPosition = Vector3.zero
|
|
end
|
|
return go
|
|
end
|
|
end
|
|
|
|
function UiFactory.GetSceneCanvas()
|
|
return UiFactory.SceneCanvas or panelMgr:GetParent("Scene")
|
|
end
|