Files
UltimateFishing/Assets/Scripts/Assembly-CSharp/LayoutDynamicFix.cs
2026-02-21 16:45:37 +08:00

59 lines
1.2 KiB
C#

using BitStrap;
using UnityEngine;
using UnityEngine.UI;
public class LayoutDynamicFix : MonoBehaviour
{
public VerticalLayoutGroup layout;
public RectTransform rectTransform;
public RectTransform scrollRectTransform;
public ScrollRect scrollRect;
public Scrollbar scrollbar;
public Vector2 bottomParameter = Vector2.zero;
private void Start()
{
Refresh();
}
private void OnEnable()
{
Refresh();
}
[Button]
public void Refresh()
{
Transform[] componentsInChildren = base.transform.GetComponentsInChildren<Transform>(false);
int num = 0;
for (int i = 0; i < componentsInChildren.Length; i++)
{
if (componentsInChildren[i].parent == base.transform)
{
num++;
}
}
layout.spacing = 0f;
rectTransform.sizeDelta = new Vector2(rectTransform.sizeDelta.x, (float)num * bottomParameter.x);
scrollRectTransform.sizeDelta = new Vector2(scrollRectTransform.sizeDelta.x, rectTransform.sizeDelta.y);
float value = scrollbar.value;
if (value < 1f)
{
scrollbar.value += 0.01f;
}
else
{
scrollbar.value -= 0.01f;
}
scrollbar.value = value;
scrollRect.CalculateLayoutInputVertical();
scrollRect.StopMovement();
Canvas.ForceUpdateCanvases();
}
}