dezhou_client/lua_probject/base_project/Game/View/Common/BaseView.lua

92 lines
1.9 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

--view 基类
--author--
---
--@type BaseView
BaseView = {
-- Id View ID
Id = 0,
-- View 是否被销毁
_is_destroy = false,
--关闭摧毁
_close_destroy = 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"
}
---
--@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)
-- self._close_destroy = true
-- -- self._view.fairyBatching = true
-- self._view:AddRelation(contentPane, RelationType.Size)
-- contentPane:AddChild(self._view)
-- self._contentPane = contentPane
-- end
function M:InitView()
self.languageText = {}
local texts = LuaUIHelper:GetAllText(self._view)
for index = 0, texts.Length - 1 do
local tempText = texts[index].text
if self.languageText[tempText] == nil then
self.languageText[tempText] = {}
end
local temp = self.languageText[tempText]
temp[#temp + 1] = { v = tempText, t = texts[index] }
end
self:ChangeLanguage()
end
function M:Show()
self._view:SetActive(true)
end
function M:ChangeLanguage()
for index, value in pairs(self.languageText) do
for i, v in ipairs(value) do
v.t.text = LanguageManager.Tex(v.v)
end
end
end
function M:Close()
self._view:SetActive(false)
end
--游戏暂停
function M:OnApplicationPause()
end
--游戏暂停
function M:OnApplicationActive()
end
---
--@function [parent=#BaseView] Destroy
--@param self
function M:Destroy()
self._is_destroy = true
UnityEngine.GameObject.Destroy(self._view)
-- self._root_view:Dispose()
end