改动与优化
This commit is contained in:
@@ -183,31 +183,46 @@ public class TeamSelectorAnimController : MonoBehaviour
|
||||
}
|
||||
if (slotRects == null || slotRects.Count == 0) yield break;
|
||||
|
||||
LayoutGroup layout = leftSlotsContainer != null ? leftSlotsContainer.GetComponent<LayoutGroup>() : null;
|
||||
bool layoutEnabled = layout != null && layout.enabled;
|
||||
if (leftSlotsContainer != null)
|
||||
LayoutRebuilder.ForceRebuildLayoutImmediate(leftSlotsContainer);
|
||||
|
||||
slotRects.Sort((a, b) => a.GetSiblingIndex().CompareTo(b.GetSiblingIndex()));
|
||||
|
||||
if (layoutEnabled) layout.enabled = false;
|
||||
|
||||
var basePosBySlot = new Dictionary<RectTransform, Vector2>(slotRects.Count);
|
||||
var canMoveBySlot = new Dictionary<RectTransform, bool>(slotRects.Count);
|
||||
for (int i = 0; i < slotRects.Count; i++)
|
||||
{
|
||||
RectTransform rt = slotRects[i];
|
||||
if (rt == null) continue;
|
||||
Vector2 basePos = rt.anchoredPosition;
|
||||
basePosBySlot[rt] = basePos;
|
||||
bool canMove = !UI_OrderedEntryAnimator.IsLayoutSensitive(rt);
|
||||
canMoveBySlot[rt] = canMove;
|
||||
rt.DOKill();
|
||||
rt.anchoredPosition = basePos + new Vector2(0f, -slotEnterOffset);
|
||||
rt.DOAnchorPos(basePos, slotEnterTime)
|
||||
.SetEase(Ease.OutCubic)
|
||||
.SetDelay(i * slotStagger)
|
||||
.SetUpdate(useUnscaled)
|
||||
// If a slot gets disabled/enabled during layout/UI updates, don't kill the tween
|
||||
// (killing it can leave the slot stuck at the start offset).
|
||||
.SetLink(rt.gameObject, LinkBehaviour.PauseOnDisablePlayOnEnable);
|
||||
|
||||
CanvasGroup cg = EnsureCanvasGroup(rt);
|
||||
if (cg != null)
|
||||
{
|
||||
cg.DOKill();
|
||||
cg.alpha = 0f;
|
||||
cg.DOFade(1f, slotEnterTime)
|
||||
.SetEase(Ease.OutCubic)
|
||||
.SetDelay(i * slotStagger)
|
||||
.SetUpdate(useUnscaled)
|
||||
.SetLink(rt.gameObject, LinkBehaviour.PauseOnDisablePlayOnEnable);
|
||||
}
|
||||
|
||||
if (canMove)
|
||||
{
|
||||
rt.anchoredPosition = basePos + new Vector2(0f, -slotEnterOffset);
|
||||
rt.DOAnchorPos(basePos, slotEnterTime)
|
||||
.SetEase(Ease.OutCubic)
|
||||
.SetDelay(i * slotStagger)
|
||||
.SetUpdate(useUnscaled)
|
||||
// If a slot gets disabled/enabled during layout/UI updates, don't kill the tween
|
||||
// (killing it can leave the slot stuck at the start offset).
|
||||
.SetLink(rt.gameObject, LinkBehaviour.PauseOnDisablePlayOnEnable);
|
||||
}
|
||||
}
|
||||
|
||||
float total = slotEnterTime + slotStagger * Mathf.Max(0, slotRects.Count - 1);
|
||||
@@ -223,6 +238,7 @@ public class TeamSelectorAnimController : MonoBehaviour
|
||||
{
|
||||
RectTransform rt = kvp.Key;
|
||||
if (rt == null) continue;
|
||||
if (!canMoveBySlot.TryGetValue(rt, out bool canMove) || !canMove) continue;
|
||||
Vector2 basePos = kvp.Value;
|
||||
if (Vector2.Distance(rt.anchoredPosition, basePos) > 0.5f)
|
||||
{
|
||||
@@ -234,7 +250,6 @@ public class TeamSelectorAnimController : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
if (layoutEnabled) layout.enabled = true;
|
||||
if (leftSlotsContainer != null)
|
||||
LayoutRebuilder.ForceRebuildLayoutImmediate(leftSlotsContainer);
|
||||
}
|
||||
@@ -281,6 +296,20 @@ public class TeamSelectorAnimController : MonoBehaviour
|
||||
void AnimatePanel(RectTransform panel, float offsetX, float delay)
|
||||
{
|
||||
if (panel == null) return;
|
||||
bool canMove = !UI_OrderedEntryAnimator.IsLayoutSensitive(panel);
|
||||
CanvasGroup cg = EnsureCanvasGroup(panel);
|
||||
if (cg != null)
|
||||
{
|
||||
cg.DOKill();
|
||||
cg.alpha = 0f;
|
||||
cg.DOFade(1f, panelEnterTime)
|
||||
.SetEase(Ease.OutCubic)
|
||||
.SetDelay(delay)
|
||||
.SetUpdate(useUnscaled)
|
||||
.SetLink(cg.gameObject, LinkBehaviour.KillOnDisable);
|
||||
}
|
||||
if (!canMove) return;
|
||||
|
||||
Vector2 basePos = panel.anchoredPosition;
|
||||
panel.DOKill();
|
||||
panel.anchoredPosition = basePos + new Vector2(offsetX, 0f);
|
||||
@@ -294,6 +323,19 @@ public class TeamSelectorAnimController : MonoBehaviour
|
||||
void AnimateConfirm(RectTransform button)
|
||||
{
|
||||
if (button == null) return;
|
||||
bool canMove = !UI_OrderedEntryAnimator.IsLayoutSensitive(button);
|
||||
CanvasGroup cg = EnsureCanvasGroup(button);
|
||||
if (cg != null)
|
||||
{
|
||||
cg.DOKill();
|
||||
cg.alpha = 0f;
|
||||
cg.DOFade(1f, confirmEnterTime)
|
||||
.SetEase(Ease.OutCubic)
|
||||
.SetUpdate(useUnscaled)
|
||||
.SetLink(cg.gameObject, LinkBehaviour.KillOnDisable);
|
||||
}
|
||||
if (!canMove) return;
|
||||
|
||||
Vector2 basePos = button.anchoredPosition;
|
||||
button.DOKill();
|
||||
button.anchoredPosition = basePos + new Vector2(0f, -confirmEnterOffset);
|
||||
|
||||
Reference in New Issue
Block a user