根据错误信息,你的代码在第98行调用 `GUI:Button_setTitleColor` 时出现了问题,错误提示是 "target is invalid cobj"。
这个错误通常有几个原因:
1. **按钮对象为空**:你传递给 `GUI:Button_setTitleColor` 的按钮对象可能是 `nil`
2. **按钮已被销毁**:按钮对象已经被移除或销毁
3. **对象类型错误**:你传递的不是一个按钮对象
检查第98行代码,确保:
```lua
-- 正确示例
if not GUI:Win_IsNull(button) then
GUI:Button_setTitleColor(button, "#ff0000") -- 设置按钮标题颜色为红色
else
SL:print("按钮对象为空!")
end
```
建议你在调用 `GUI:Button_setTitleColor` 前先判断对象是否有效:
```lua
local button = GUI:getChildByName(parent, "你的按钮ID")
if button and not GUI:Win_IsNull(button) then
GUI:Button_setTitleColor(button, "#ff0000")
else
SL:print("无法找到按钮对象或按钮已失效")
end
```
另外,检查按钮的创建代码,确保按钮正确创建并且没有在别处被意外移除。如果还是解决不了,可以把相关代码发给我看看。