2023-07-14 19:35:33 +00:00
|
|
|
local pairs = pairs
|
|
|
|
local tableInsert = table.insert
|
2024-09-01 20:49:41 +00:00
|
|
|
local SPINE_INDEX_OFFSET = 100 -- spine位置的偏移值
|
2023-07-14 19:35:33 +00:00
|
|
|
|
|
|
|
local XMovieActionSetGray = XClass(XMovieActionBase, "XMovieActionSetGray")
|
|
|
|
|
|
|
|
function XMovieActionSetGray:Ctor(actionData)
|
|
|
|
local params = actionData.Params
|
|
|
|
local paramToNumber = XDataCenter.MovieManager.ParamToNumber
|
|
|
|
|
|
|
|
self.Value = XMath.Clamp(paramToNumber(params[1]), 0, 1)
|
|
|
|
self.IndexList = {}
|
|
|
|
local maxParamNum = XMovieConfigs.MAX_ACTOR_NUM + 1
|
|
|
|
for i = 1, maxParamNum do
|
|
|
|
local index = paramToNumber(params[i + 1])
|
|
|
|
if index ~= 0 then
|
|
|
|
tableInsert(self.IndexList, index)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function XMovieActionSetGray:OnRunning()
|
|
|
|
local value = self.Value
|
|
|
|
local maxActorNum = XMovieConfigs.MAX_ACTOR_NUM
|
|
|
|
local indexList = self.IndexList
|
|
|
|
local setValue = false
|
|
|
|
|
|
|
|
for _, index in pairs(indexList) do
|
2024-09-01 20:49:41 +00:00
|
|
|
if index > 0 and index <= maxActorNum then
|
2023-07-14 19:35:33 +00:00
|
|
|
local actor = self.UiRoot:GetActor(index)
|
|
|
|
actor:SetGrayScale(value)
|
|
|
|
setValue = true
|
2024-09-01 20:49:41 +00:00
|
|
|
elseif index > SPINE_INDEX_OFFSET and index <= SPINE_INDEX_OFFSET + maxActorNum then
|
|
|
|
local actor = self.UiRoot:GetSpineActor(index - SPINE_INDEX_OFFSET)
|
|
|
|
actor:SetGrayScale(value)
|
|
|
|
setValue = true
|
2023-07-14 19:35:33 +00:00
|
|
|
else
|
|
|
|
self.UiRoot.MaterialBg:SetGrayScale(value)
|
2024-09-01 20:49:41 +00:00
|
|
|
self:SetLeftTitleGray(value)
|
2023-07-14 19:35:33 +00:00
|
|
|
setValue = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if not setValue then
|
|
|
|
self.UiRoot.MaterialBg:SetGrayScale(value)
|
2024-09-01 20:49:41 +00:00
|
|
|
self:SetLeftTitleGray(value)
|
2023-07-14 19:35:33 +00:00
|
|
|
for index = 1, maxActorNum do
|
|
|
|
local actor = self.UiRoot:GetActor(index)
|
|
|
|
actor:SetGrayScale(value)
|
|
|
|
end
|
2024-09-01 20:49:41 +00:00
|
|
|
|
|
|
|
for index = 1, XMovieConfigs.MAX_SPINE_ACTOR_NUM do
|
|
|
|
local actor = self.UiRoot:GetSpineActor(index)
|
|
|
|
actor:SetGrayScale(value)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- 设置左边标题的灰度
|
|
|
|
function XMovieActionSetGray:SetLeftTitleGray(value)
|
|
|
|
local controllerComponents = self.UiRoot.PanelLeftTitle:GetComponentsInChildren(typeof(CS.XUiMaterialController))
|
|
|
|
for i = 0, controllerComponents.Length - 1 do
|
|
|
|
local controller = controllerComponents[i]
|
|
|
|
controller:SetGrayScale(value)
|
2023-07-14 19:35:33 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return XMovieActionSetGray
|