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