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

31 lines
812 B
C#

using UnityEngine;
using UnityEngine.UI;
public class MenuButton : MonoBehaviour
{
public Text text;
public Image background;
public Image backgroundActive;
private void Start()
{
UpdateBackground();
}
private void OnEnable()
{
UpdateBackground();
}
public void UpdateBackground()
{
float preferredWidth = text.preferredWidth;
background.rectTransform.sizeDelta = new Vector2(preferredWidth + 85f, background.rectTransform.sizeDelta.y);
background.rectTransform.anchoredPosition = new Vector2(-110f, background.rectTransform.anchoredPosition.y);
backgroundActive.rectTransform.sizeDelta = new Vector2(background.rectTransform.sizeDelta.x + 6f, background.rectTransform.sizeDelta.y);
backgroundActive.rectTransform.anchoredPosition = background.rectTransform.anchoredPosition;
}
}