展前冒死重构
This commit is contained in:
@@ -562,6 +562,11 @@ public class UI_Idols : MonoBehaviour
|
||||
SetText(idolBackNameText, hero.ally_heroName);
|
||||
SetText(idol_chenghaoText, hero.ally_heroDesignation);
|
||||
SetText(idol_nameText, hero.ally_heroName);
|
||||
// 名字文本挂 ContentSizeFitter(H+V=Preferred):改文字后布局要到帧末才 rebuild,
|
||||
// 期间会以旧尺寸显示一帧、下一帧才修正,表现为"名字偏移后恢复"。这里立即强制重建,消除该帧。
|
||||
ForceRebuildText(idol_nameText);
|
||||
ForceRebuildText(idolBackNameText);
|
||||
ForceRebuildText(idol_chenghaoText);
|
||||
SetIdolDocumentText(hero.ally_heroDescription);
|
||||
bool animateExpBar = pendingGrowthAnimationHeroId > 0 && hero.ally_heroID == pendingGrowthAnimationHeroId;
|
||||
SetSliderVisual(idol_expBar, snapshot.sliderValue, snapshot.sliderColor, animateExpBar);
|
||||
@@ -579,7 +584,8 @@ public class UI_Idols : MonoBehaviour
|
||||
ApplyBehaviourRadar(hero);
|
||||
|
||||
PopulateSpecialSkills(hero);
|
||||
UI_OrderedEntryAnimator.PlayRefresh(rightPanel, 0.16f, -8f, 0.99f, true);
|
||||
// 改用只淡入的动画,避免位移导致名字跳动
|
||||
UI_OrderedEntryAnimator.PlayFadeOnly(rightPanel, 0, 0.2f, 0f, true);
|
||||
}
|
||||
|
||||
private void SetIdolDocumentText(string value)
|
||||
@@ -889,6 +895,19 @@ public class UI_Idols : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
// 改完文字后立即重建其(及自身)布局,让 ContentSizeFitter 当帧算好尺寸,
|
||||
// 避免"旧尺寸显示一帧→下一帧修正"的偏移跳动。仅对挂了 ContentSizeFitter 的文本有意义,
|
||||
// 对普通文本也无害(RebuildLayoutImmediate 开销很小、每次切换偶像才调用几次)。
|
||||
private static void ForceRebuildText(Text target)
|
||||
{
|
||||
if (target == null) return;
|
||||
RectTransform rt = target.rectTransform;
|
||||
if (rt != null)
|
||||
{
|
||||
UnityEngine.UI.LayoutRebuilder.ForceRebuildLayoutImmediate(rt);
|
||||
}
|
||||
}
|
||||
|
||||
private static void SetImageSprite(Image target, Sprite sprite)
|
||||
{
|
||||
if (target == null)
|
||||
|
||||
Reference in New Issue
Block a user