【内存优化】修复资源卸载时会错误卸载其他界面的问题

dev_chengFeng
gaoxin 2021-04-21 22:45:37 +08:00
parent dd667ae26a
commit e277760221
3 changed files with 27 additions and 28 deletions

View File

@ -3,10 +3,10 @@ local SpriteLoader = {}
-- 调用此方法创建一个管理器 -- 调用此方法创建一个管理器
function SpriteLoader.New() function SpriteLoader.New()
-- 判断对象池里有没有 -- -- 判断对象池里有没有
if #SpriteLoaderPool > 0 then -- if #SpriteLoaderPool > 0 then
return table.remove(SpriteLoaderPool, 1) -- return table.remove(SpriteLoaderPool, 1)
end -- end
-- 没有新建 -- 没有新建
local o = {} local o = {}
o.SpriteList = {} o.SpriteList = {}

View File

@ -144,7 +144,7 @@ function this.SetSpriteBG(sprite)
end end
function this.Exit() function this.Exit()
-- this.spLoader:Destroy() this.spLoader:Destroy()
_tileLivePool = nil _tileLivePool = nil
_tileClearPool = nil _tileClearPool = nil
ViewCamera = nil ViewCamera = nil

View File

@ -1,6 +1,5 @@
----- 元素共鸣 ----- ----- 元素共鸣 -----
ElementalResonanceView = {} ElementalResonanceView = {}
local this = ElementalResonanceView
local propertyConfig = ConfigManager.GetConfig(ConfigName.PropertyConfig) local propertyConfig = ConfigManager.GetConfig(ConfigName.PropertyConfig)
local monsterConfig = ConfigManager.GetConfig(ConfigName.MonsterConfig) local monsterConfig = ConfigManager.GetConfig(ConfigName.MonsterConfig)
local heroConfig = ConfigManager.GetConfig(ConfigName.HeroConfig) local heroConfig = ConfigManager.GetConfig(ConfigName.HeroConfig)
@ -16,56 +15,56 @@ function ElementalResonanceView:New(gameObject)
return b return b
end end
function this:InitComponent() function ElementalResonanceView:InitComponent()
this.spLoader = SpriteLoader.New() self.spLoader = SpriteLoader.New()
self.elementalResonanceBtn = Util.GetGameObject(self.gameObject, "elementalResonanceBtn") self.elementalResonanceBtn = Util.GetGameObject(self.gameObject, "elementalResonanceBtn")
this.orginLayer = 0 self.orginLayer = 0
this.effect = Util.GetGameObject(self.elementalResonanceBtn, "effect") self.effect = Util.GetGameObject(self.elementalResonanceBtn, "effect")
self.elementalResonanceImage = Util.GetGameObject(self.gameObject, "elementalResonanceBtn/bgImage/Image"):GetComponent("Image") self.elementalResonanceImage = Util.GetGameObject(self.gameObject, "elementalResonanceBtn/bgImage/Image"):GetComponent("Image")
end end
function this:BindEvent() function ElementalResonanceView:BindEvent()
-- 功能开启列表 -- 功能开启列表
Util.AddClick(self.elementalResonanceBtn, function() Util.AddClick(self.elementalResonanceBtn, function()
UIManager.OpenPanel(UIName.ElementPopup, self.dataTable,this.thisPanelOrder) UIManager.OpenPanel(UIName.ElementPopup, self.dataTable,self.thisPanelOrder)
end) end)
end end
function this:AddListener() function ElementalResonanceView:AddListener()
end end
function this:RemoveListener() function ElementalResonanceView:RemoveListener()
end end
function this:OnOpen(context) function ElementalResonanceView:OnOpen(context)
if context then if context then
this.SetOrderStatus(context) self:SetOrderStatus(context)
end end
end end
function this:OnClose() function ElementalResonanceView:OnClose()
UIManager.ClosePanel(UIName.ElementPopup) UIManager.ClosePanel(UIName.ElementPopup)
this.spLoader:Destroy() self.spLoader:Destroy()
end end
--设定层级 --设定层级
function this.SetOrderStatus(context) function ElementalResonanceView:SetOrderStatus(context)
if not context then if not context then
return return
end end
local sortingOrder = context.sortOrder + 90 local sortingOrder = context.sortOrder + 90
-- Log("<color=yellow>"..sortOrder.."</color>") -- Log("<color=yellow>"..sortOrder.."</color>")
this.thisPanelOrder = context.sortOrder self.thisPanelOrder = context.sortOrder
--self.transform:GetComponent("Canvas").sortingOrder = sortingOrder --self.transform:GetComponent("Canvas").sortingOrder = sortingOrder
Util.AddParticleSortLayer(this.effect, sortingOrder - this.orginLayer) Util.AddParticleSortLayer(self.effect, sortingOrder - self.orginLayer)
this.orginLayer = sortingOrder self.orginLayer = sortingOrder
end end
--得到元素共鸣类型 --得到元素共鸣类型
-- 1.火 2.风 3.水 4.大地 -- 1.火 2.风 3.水 4.大地
function this:GetElementalType(curFormation, type) function ElementalResonanceView:GetElementalType(curFormation, type)
elementPropertyList = {} elementPropertyList = {}
local fireElementNum = 0 local fireElementNum = 0
local windyElementNum = 0 local windyElementNum = 0
@ -150,16 +149,16 @@ function this:GetElementalType(curFormation, type)
local isShow = false local isShow = false
isShow = indexChoose > 0 isShow = indexChoose > 0
if (isShow == false) then if (isShow == false) then
self.elementalResonanceImage.sprite = this.spLoader:LoadSprite("r_zhandou_yuansu_01") self.elementalResonanceImage.sprite = self.spLoader:LoadSprite("r_zhandou_yuansu_01")
else else
if indexChoose > 0 then if indexChoose > 0 then
self.elementalResonanceImage.sprite = this.spLoader:LoadSprite(ImageList[indexChoose]) self.elementalResonanceImage.sprite = self.spLoader:LoadSprite(ImageList[indexChoose])
end end
end end
this.effect:SetActive(isShow) self.effect:SetActive(isShow)
end end
function this:SetPosition(type) function ElementalResonanceView:SetPosition(type)
if (type == 1) then if (type == 1) then
-- self.elementalResonanceBtn.transform.localPosition = Vector3.New(455, 783, 0) -- self.elementalResonanceBtn.transform.localPosition = Vector3.New(455, 783, 0)
self.elementalResonanceBtn.gameObject:GetComponent("RectTransform").anchorMin = Vector2.New(1, 1) self.elementalResonanceBtn.gameObject:GetComponent("RectTransform").anchorMin = Vector2.New(1, 1)
@ -181,6 +180,6 @@ function this:SetPosition(type)
end end
end end
function this:SetElementalPropertyTextColor() function ElementalResonanceView:SetElementalPropertyTextColor()
end end
return ElementalResonanceView return ElementalResonanceView