local MaintenanceNoticeUI = class("MaintenanceNoticeUI", BaseUI) function MaintenanceNoticeUI:isFullScreen() return false end function MaintenanceNoticeUI:ctor(params) self.content = params and params.content self.openTime = params and params.openTime or 0 end function MaintenanceNoticeUI:getPrefabPath() return "assets/prefabs/ui/login/maintenance_notice_ui.prefab" end function MaintenanceNoticeUI:onLoadRootComplete() local uiMap = self.root:genAllChildren() uiMap["maintenance_notice_ui.bg.title_bg.title_tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.NOTICE_TITLE)) local contentTx = uiMap["maintenance_notice_ui.bg.img_2.scrollrect.viewport.content.content_tx"] if self.content == nil or self.content == "" then contentTx:setText(I18N:getGlobalText(I18N.GlobalConst.MAINTENANCE_NOTICE_DEFAULT)) else contentTx:setText(self.content) end local scrollRectHeight = uiMap["maintenance_notice_ui.bg.img_2.scrollrect"]:getRectHeight() local topOffset = -contentTx:fastGetAnchoredPositionY() contentTx:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO):ForceMeshUpdate() local height = contentTx:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO).renderedHeight if height > scrollRectHeight then uiMap["maintenance_notice_ui.bg.img_2.scrollrect"]:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_SCROLL_RECT).movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Elastic uiMap["maintenance_notice_ui.bg.img_2.scrollrect.viewport.content"]:setSizeDeltaY(height + topOffset*2) else uiMap["maintenance_notice_ui.bg.img_2.scrollrect"]:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_SCROLL_RECT).movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Clamped uiMap["maintenance_notice_ui.bg.img_2.scrollrect.viewport.content"]:setSizeDeltaY(scrollRectHeight) end uiMap["maintenance_notice_ui.bg.img_2.scrollrect.viewport.content"]:setAnchoredPositionY(0) uiMap["maintenance_notice_ui.bg.ok_btn"]:addClickListener(function() self:closeUI() local clientTime = ModuleManager.LoginManager:getServerTime()*1000 if clientTime >= self.openTime then ModuleManager.LoginManager:resetServerListStartTime() ModuleManager.LoginManager:getServerList() else ModuleManager.LoginManager:checkServerOpen() end end) uiMap["maintenance_notice_ui.bg.ok_btn.text"]:setText(I18N:getGlobalText(I18N.GlobalConst.BTN_TEXT_OK)) end return MaintenanceNoticeUI