if SL:GetMetaValue("GAME_DATA", "NeedResetPosWithChat") then
local idList = string.split(SL:GetMetaValue("GAME_DATA", "NeedResetPosWithChat"), "#")
for _, id in ipairs(idList) do
local i = tonumber(id)
要实现 `yinc` 控件的隐藏和显示,需要根据聊天框的状态来控制。从你的代码来看,当前只在聊天框展开时隐藏了 `yinc`,但没有在收起时重新显示。
修改后的代码应该这样写:
```lua
local yinc = GUI:Win_FindParent(108)
if not tolua.isnull(yinc) then
if not state then
-- 聊天框展开时隐藏 yinc
GUI:setVisible(yinc, false)
else
-- 聊天框收起时显示 yinc
GUI:setVisible(yinc, true)
end
end
```
关键点:
1. **先检查控件是否有效**:使用 `if not tolua.isnull(yinc) then` 确保控件存在
2. **根据状态切换显示/隐藏**:
- `not state`(聊天框展开)→ 隐藏
- `state`(聊天框收起)→ 显示
3. **使用正确的函数**:`GUI:setVisible(widget, value)` 控制可见性
建议将这个代码放在聊天框状态变化的逻辑中,确保每次状态改变时都会执行。