You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

37 lines
872 B

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class TabWrapTop : MonoBehaviour
{
[SerializeField]
ScrollRect scrollTopBar;
GameObject leftArrow;
GameObject rightArrow;
void Start()
{
leftArrow = scrollTopBar.transform.Find("LeftArrow").gameObject;
rightArrow = scrollTopBar.transform.Find("RightArrow").gameObject;
scrollTopBar.onValueChanged.AddListener(OnScrollChanged);
}
void OnScrollChanged(Vector2 scrollPosition)
{
if (scrollPosition.x <= 0.01f)
{
leftArrow.SetActive(false);
}
else if (scrollPosition.x >= 0.99f)
{
rightArrow.SetActive(false);
}
else
{
leftArrow.SetActive(true);
rightArrow.SetActive(true);
}
}
}