--view 基类 --author:-- --- --@type BaseView BaseView = { -- Id View ID Id = 0, -- View 是否被销毁 _is_destroy = false, --关闭摧毁 _close_destroy = false, --缩放全屏 _scale = false, -- 全屏 _full = false, --全屏偏移 _full_offset = true, --view description _view = nil, } local M = BaseView local view_url = { "ui://Common/Gcm_BaseView", "ui://Common/Gcm_BaseView_Full" } local _views = {} --- --@function [parent=#BaseView] InitView --@param self --@param #string url function M:InitView(url) self._root_view = UIPackage.CreateObjectFromURL(self._full and view_url[2] or view_url[1]) local contentPane = self._root_view:GetChild("contentPane") self._view = UIPackage.CreateObjectFromURL(url) printlog(self._view, url) self._close_destroy = true -- self._view.fairyBatching = true self._view:AddRelation(contentPane, RelationType.Size) contentPane:AddChild(self._view) self._contentPane = contentPane _views[self.class] = self end function M:Show() self._root_view.visible = true if not self._root_view.parent then AddPanel(self._root_view) if self._full then local offset = get_offset(self._full_offset) self._contentPane.width = GRoot.inst.width - (offset * 2) self._contentPane.height = GRoot.inst.height self._contentPane.x = offset end if self._scale then local scaleY = GRoot.inst.height / self._contentPane.height local scaleX = GRoot.inst.width / self._contentPane.width self._contentPane:SetScale(scaleX, scaleY) end end end function M:Close() self._root_view.visible = false end --游戏暂停 function M:OnApplicationPause() end --游戏暂停 function M:OnApplicationActive() end --- --@function [parent=#BaseView] Destroy --@param self function M:Destroy() self:Close() self._is_destroy = true self._root_view:Dispose() _views[self.class] = nil end function BaseView.FindView(class) return _views[class] or nil end