---@type Ability?
local current_ability
---@type Item?
local current_item
---@type UI?
local current_ui
local tips = y3.local_ui.create('HeroInfo.tips_node')
for i = 1, #UI_path_table.main.ability - 1 do
local index = i
local path = 'HeroInfo.main.skill_list.skill_btn_' .. index
y3.local_ui.create(path):on_event('skill_btn', '鼠标-移入', function(ui, local_player, instance)
local abilitys = Get_player_hero(local_player):get_abilities_by_type(y3.const.AbilityCategory.HERO_ABILITY)
current_ability = abilitys[index]
current_ui = ui
tips:refresh('*')
end)
y3.local_ui.create(path):on_event('skill_btn', '鼠标-移出', function(ui, local_player, instance)
current_ability = nil
current_ui = nil
tips:refresh('*')
end)
end
for i = 1, #UI_path_table.main.inventorys - 1 do
local index = i
local path = 'HeroInfo.main.inventory.equip_slot_bg_' .. index
y3.local_ui.create(path):on_event('equip_slot_1', '鼠标-移入', function(ui, local_player, instance)
current_item = local_player:get_selecting_unit():get_item_by_slot('物品栏', index)
current_ui = ui
tips:refresh('*')
end)
y3.local_ui.create(path):on_event('equip_slot_1', '鼠标-移出', function(ui, local_player, instance)
current_item = nil
current_ui = nil
tips:refresh('*')
end)
end
tips:on_refresh('', function(ui, local_player)
if current_ability or current_item then
ui:set_visible(true)
else
ui:set_visible(false)
end
if not current_ui then
return
end
ui:set_absolute_pos(current_ui:get_absolute_x() - 200, current_ui:get_absolute_y() + 300)
end)
tips:on_refresh('header.name', function(ui, local_player)
if current_ability then
ui:set_text(current_ability:get_name())
elseif current_item then
ui:set_text(current_item:get_name())
else
return
end
end)
装备UI结构如下:
提示UI如下:
调试显示如下:
报错信息如下:
[08-24 20:00:03.833][error][.../maps/EntryMap/script/y3\object\editable_object\item.lua:621]: .../maps/EntryMap/script/y3\object\editable_object\item.lua:621: attempt to call a nil value (method 'api_is_destroyed')
stack traceback:
.../maps/EntryMap/script/y3\object\editable_object\item.lua:621: in function 'y3.object.editable_object.item.is_destroyed'
.../maps/EntryMap/script/y3\util\ref.lua:157: in function <.../maps/EntryMap/script/y3\util\ref.lua:145>
[C]: in function 'xpcall'
.../maps/EntryMap/script/y3\util\local_timer.lua:112: in function 'y3.util.local_timer.execute'
.../maps/EntryMap/script/y3\util\local_timer.lua:99: in function 'y3.util.local_timer.wakeup'
.../maps/EntryMap/script/y3\util\local_timer.lua:333: in function <.../maps/EntryMap/script/y3\util\local_timer.lua:315>
[C]: in function 'xpcall'
.../maps/EntryMap/script/y3\object\runtime_object\timer.lua:228: in function 'y3.object.runtime_object.timer.execute'
.../maps/EntryMap/script/y3\object\runtime_object\timer.lua:164: in function <.../maps/EntryMap/script/y3\object\runtime_object\timer.lua:162>
[C]: in local 'f'
.../maps/EntryMap/script/y3\object\runtime_object\timer.lua:71: in function <.../maps/EntryMap/script/y3\object\runtime_object\timer.lua:70>
在使用 “演示.demo.界面” 的方法显示技能或者物品提示UI时,技能提示显示正常,物品提示虽然能正常,但是马上就会出现报错信息。使用的UI和代码基本都是自带的改了改,不知道哪里出了问题。请求帮忙解答,看看是不是bug。
部分代码如下:
装备UI结构如下:
提示UI如下:
调试显示如下:
报错信息如下: [08-24 20:00:03.833][error][.../maps/EntryMap/script/y3\object\editable_object\item.lua:621]: .../maps/EntryMap/script/y3\object\editable_object\item.lua:621: attempt to call a nil value (method 'api_is_destroyed') stack traceback: .../maps/EntryMap/script/y3\object\editable_object\item.lua:621: in function 'y3.object.editable_object.item.is_destroyed' .../maps/EntryMap/script/y3\util\ref.lua:157: in function <.../maps/EntryMap/script/y3\util\ref.lua:145> [C]: in function 'xpcall' .../maps/EntryMap/script/y3\util\local_timer.lua:112: in function 'y3.util.local_timer.execute' .../maps/EntryMap/script/y3\util\local_timer.lua:99: in function 'y3.util.local_timer.wakeup' .../maps/EntryMap/script/y3\util\local_timer.lua:333: in function <.../maps/EntryMap/script/y3\util\local_timer.lua:315> [C]: in function 'xpcall' .../maps/EntryMap/script/y3\object\runtime_object\timer.lua:228: in function 'y3.object.runtime_object.timer.execute' .../maps/EntryMap/script/y3\object\runtime_object\timer.lua:164: in function <.../maps/EntryMap/script/y3\object\runtime_object\timer.lua:162> [C]: in local 'f' .../maps/EntryMap/script/y3\object\runtime_object\timer.lua:71: in function <.../maps/EntryMap/script/y3\object\runtime_object\timer.lua:70>