优化rendertexture的数量20->6
parent
ce13a0263e
commit
b5ab2384c3
File diff suppressed because it is too large
Load Diff
|
@ -10,7 +10,7 @@ function CardRendererManager.Initialize()
|
|||
GameObject.DontDestroyOnLoad(this.root)
|
||||
this.renderList = {}
|
||||
this.textureList = {}
|
||||
for i = 1, 20 do
|
||||
for i = 1, 6 do
|
||||
this.renderList[i] = Util.GetGameObject(this.root, "CardRenderer"..i.."/Canvas")
|
||||
this.textureList[i] = resMgr:LoadAsset("CardTexture"..i)
|
||||
end
|
||||
|
@ -23,19 +23,19 @@ end
|
|||
|
||||
-- 获取RenderTexture对象
|
||||
--- isReuse 是否可以复用已经存在的Texture
|
||||
function CardRendererManager.GetSpineTexture(liveName, scaleV3, posV3, isReuse, onClear)
|
||||
function CardRendererManager.GetSpineTexture(pos, liveName, scaleV3, posV3, isReuse, onClear)
|
||||
-- 可复用,判断之前是否存在
|
||||
if isReuse then
|
||||
local index = this.CheckIsExist(liveName)
|
||||
if index then
|
||||
return this.textureList[index], this.liveList[index].node
|
||||
end
|
||||
end
|
||||
-- if isReuse then
|
||||
-- local index = this.CheckIsExist(liveName)
|
||||
-- if index then
|
||||
-- return this.textureList[index], this.liveList[index].node
|
||||
-- end
|
||||
-- end
|
||||
-- flag
|
||||
this.indexFlag = this.indexFlag + 1
|
||||
if this.indexFlag > 20 then
|
||||
this.indexFlag = 1
|
||||
end
|
||||
this.indexFlag = pos --this.indexFlag + 1
|
||||
-- if this.indexFlag > 20 then
|
||||
-- this.indexFlag = 1
|
||||
-- end
|
||||
-- 回收老资源
|
||||
local liveData = this.liveList[this.indexFlag]
|
||||
if liveData then
|
||||
|
|
|
@ -23,7 +23,7 @@ function this.SetData(_fightData)
|
|||
for _, data in ipairs(this.fightData.playerData) do
|
||||
local pos = data.position
|
||||
this.heroNodeList[pos]:SetActive(true)
|
||||
this.SetCardSingleData(this.heroNodeList[pos], data)
|
||||
this.SetCardSingleData(this.heroNodeList[pos], data, pos)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -51,7 +51,7 @@ end
|
|||
|
||||
|
||||
--设置单个上阵英雄信息
|
||||
function this.SetCardSingleData(o, data)
|
||||
function this.SetCardSingleData(o, data, pos)
|
||||
-- local live = Util.GetGameObject(o, "Mask/Live")
|
||||
local bg=Util.GetGameObject(o,"Bg1"):GetComponent("Image")
|
||||
local fg=Util.GetGameObject(o,"Bg2"):GetComponent("Image")
|
||||
|
@ -67,7 +67,7 @@ function this.SetCardSingleData(o, data)
|
|||
local live = Util.GetGameObject(o, "Mask/icon"):GetComponent("RawImage")
|
||||
local liveName = GetResourcePath(heroConfig.Live)
|
||||
local roleConfig = ConfigManager.GetConfigData(ConfigName.RoleConfig, heroConfig.Id)
|
||||
live.texture = CardRendererManager.GetSpineTexture(liveName, Vector3.one * roleConfig.play_liveScale, Vector3.zero, true)
|
||||
live.texture = CardRendererManager.GetSpineTexture(pos, liveName, Vector3.one * roleConfig.play_liveScale, Vector3.zero, true)
|
||||
local liveScale = Vector3.one-- * roleConfig.play_liveScale * 2
|
||||
local livePos = Vector2.New(roleConfig.offset[1], roleConfig.offset[2])
|
||||
live.transform.localScale = liveScale
|
||||
|
|
|
@ -127,7 +127,7 @@ function RoleView.New(go, role, position, root)
|
|||
end
|
||||
|
||||
instance.liveRender = Util.GetGameObject(go, "Mask/icon"):GetComponent("RawImage")
|
||||
instance.liveRender.texture, instance.RoleLiveGO = CardRendererManager.GetSpineTexture(instance.livePath, Vector3.one * instance.play_liveScale, Vector3.New(instance.offset[1], instance.offset[2], 0), false) --Util.LoadSprite(heroData.painting)
|
||||
instance.liveRender.texture, instance.RoleLiveGO = CardRendererManager.GetSpineTexture(role.position, instance.livePath, Vector3.one * instance.play_liveScale, Vector3.New(instance.offset[1], instance.offset[2], 0), false) --Util.LoadSprite(heroData.painting)
|
||||
instance.liveRender.material = resMgr:LoadAsset("UI_AlphaMask "..position)
|
||||
else
|
||||
instance.RoleLiveGO = poolManager:LoadLive(instance.livePath, go.transform.parent, Vector3.one, Vector3.zero)
|
||||
|
|
|
@ -124,7 +124,7 @@ function this:FormationAdapter()
|
|||
FindFairyManager.ResetItemView(this.root,this.root.transform,itemList,5,1,sortingOrder,false,rewardData)
|
||||
end
|
||||
--设置单个上阵英雄信息
|
||||
function this.SetCardSingleData(o,monsterId,_pos)
|
||||
function this.SetCardSingleData(o,monsterId, _pos)
|
||||
local heroConfig = ConfigManager.GetConfigData(ConfigName.HeroConfig, monsterId.heroTid)
|
||||
local bg=Util.GetGameObject(o,"Bg1"):GetComponent("Image")
|
||||
local fg=Util.GetGameObject(o,"Bg2"):GetComponent("Image")
|
||||
|
@ -144,7 +144,7 @@ function this.SetCardSingleData(o,monsterId,_pos)
|
|||
local roleConfig = ConfigManager.GetConfigData(ConfigName.RoleConfig, heroConfig.Id)
|
||||
local scale = roleConfig.play_liveScale
|
||||
local livePos = Vector3.New(roleConfig.offset[1], roleConfig.offset[2], 0)
|
||||
live.texture = CardRendererManager.GetSpineTexture(liveName, Vector3.one * scale, livePos, true)
|
||||
live.texture = CardRendererManager.GetSpineTexture(_pos, liveName, Vector3.one * scale, livePos, true)
|
||||
live.transform.localScale = Vector3.one
|
||||
live.transform.localPosition = Vector3.zero
|
||||
|
||||
|
|
|
@ -381,7 +381,7 @@ function this.SetCardSingleData(o, heroId, _pos, _heroData)
|
|||
local roleConfig = ConfigManager.GetConfigData(ConfigName.RoleConfig, heroData.heroConfig.Id)
|
||||
local scale = roleConfig.play_liveScale
|
||||
local livePos = Vector3.New(roleConfig.offset[1], roleConfig.offset[2], 0)
|
||||
live.texture = CardRendererManager.GetSpineTexture(liveName, Vector3.one * scale, livePos, true)
|
||||
live.texture = CardRendererManager.GetSpineTexture(_pos, liveName, Vector3.one * scale, livePos, true)
|
||||
live.transform.localScale = Vector3.one
|
||||
live.transform.localPosition = Vector3.zero
|
||||
|
||||
|
@ -829,6 +829,9 @@ function this.SetOneKeyGo()
|
|||
end
|
||||
end
|
||||
end
|
||||
if #heros == 0 then
|
||||
return
|
||||
end
|
||||
--缺几个空位 就上几个空位
|
||||
for n = 1, #posArr do
|
||||
table.insert(this.choosedList, {heroId = heros[n].dynamicId, position=posArr[n]})
|
||||
|
|
|
@ -199,7 +199,7 @@ function this.SetCardSingleData(o, heroId, _pos, heroData)
|
|||
local roleConfig = ConfigManager.GetConfigData(ConfigName.RoleConfig, heroId)
|
||||
local scale = roleConfig.play_liveScale
|
||||
local livePos = Vector3.New(roleConfig.offset[1], roleConfig.offset[2], 0)
|
||||
live.texture = CardRendererManager.GetSpineTexture(liveName, Vector3.one * scale, livePos, true)
|
||||
live.texture = CardRendererManager.GetSpineTexture(_pos, liveName, Vector3.one * scale, livePos, true)
|
||||
live.transform.localScale = Vector3.one
|
||||
live.transform.localPosition = Vector3.zero
|
||||
|
||||
|
|
Loading…
Reference in New Issue