miduo_client/Assets/ManagedResources/~Lua/Framework/Manager/RoleRenderManager.lua

67 lines
1.9 KiB
Lua

RoleRenderManager = {}
local this = RoleRenderManager
function this.Init()
RRenderMgr:Init(UIManager.camera)
this.root = RRenderMgr.root.transform
this.indexFlag = 0
this.liveList = {}
this.usingList = {}
this.materialList = {}
end
function this.SetRenderLive(pos, liveName, scaleV3, posV3, isReuse, onClear)
this.indexFlag = pos --this.indexFlag + 1
-- 回收老资源
local liveData = this.liveList[this.indexFlag]
if liveData then
local liveName = liveData.name
local liveNode = liveData.node
poolManager:UnLoadLive(liveName, liveNode)
this.liveList[this.indexFlag] = nil
RRenderMgr:ClearRender(pos)
end
-- 创建新资源
local liveNode = poolManager:LoadLive(liveName, this.root, scaleV3, posV3 + Vector3(0, -120, 0), onClear)
this.liveList[this.indexFlag] = {
name = liveName,
node = liveNode
}
this.materialList[this.indexFlag] = RRenderMgr:SetCardRender(pos, liveNode)
--
LogGreen(this.materialList[this.indexFlag].name)
return this.materialList[this.indexFlag], this.liveList[this.indexFlag].node, this.indexFlag
end
-- 判断是否存在
function this.CheckIsExist(liveName)
for index, data in ipairs(this.liveList) do
if data.name == liveName then
return index
end
end
end
-- 获取渲染的立绘
function this.GetRenderMaterial(pos)
if not this.materialList[pos] then
this.materialList[pos] = RRenderMgr:GetCardRender(pos)
end
return this.materialList[pos]
end
--
function this.Dispose()
for _, data in pairs(this.liveList) do
local liveName = data.name
local liveNode = data.node
poolManager:UnLoadLive(liveName, liveNode)
end
this.indexFlag = 0
this.liveList = {}
this.usingList = {}
this.materialList = {}
RRenderMgr:ClearAllRender()
end