From f47a35f2e7855f6f72b39486a047b4a38156ba8f Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 21 Jun 2023 15:17:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=98=BE=E7=A4=BAfix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/global/global_func.lua | 12 ++++++++++++ lua/app/ui/dungeon/dungeon_difficulty_ui.lua | 2 ++ 2 files changed, 14 insertions(+) diff --git a/lua/app/global/global_func.lua b/lua/app/global/global_func.lua index cd7018e3..53658360 100644 --- a/lua/app/global/global_func.lua +++ b/lua/app/global/global_func.lua @@ -1355,6 +1355,18 @@ function GFunc.centerImgAndTx(imgObj, txObj, spacing, offset) txObj:setAnchoredPositionX(w - txW / 2 + offset) end +-- centerImgAndTx的位置反向版本 +function GFunc.centerTxAndImg(txObj, imgObj, spacing, offset) + spacing = spacing or 0 + offset = offset or 0 + local imgW = imgObj:getSizeDelta().x + local txW = txObj:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO).preferredWidth + txObj:setSizeDeltaX(txW) + local w = (imgW + txW + spacing) / 2 + txObj:setAnchoredPositionX(txW / 2 - w + offset) + imgObj:setAnchoredPositionX(w - imgW / 2 + offset) +end + function GFunc.centerTxAndTx(txObj1, txObj2, spacing) spacing = spacing or 0 local txW = txObj1:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO).preferredWidth diff --git a/lua/app/ui/dungeon/dungeon_difficulty_ui.lua b/lua/app/ui/dungeon/dungeon_difficulty_ui.lua index 395cf33b..394e78b2 100644 --- a/lua/app/ui/dungeon/dungeon_difficulty_ui.lua +++ b/lua/app/ui/dungeon/dungeon_difficulty_ui.lua @@ -138,6 +138,8 @@ function DungeonDifficultyUI:refreshDifficulty() self.iconBuff:addClickListener(function() ModuleManager.TipsManager:showDescTips(GFunc.getBuffDesc(buff.type, buff.num), self.iconBuff) end) + + GFunc.centerTxAndImg(self.txbuff, self.iconBuff, 5) else self.buffObj:setActive(false) end