chicken_dy/Assets/Scripts/UI/CustomControl/PageSpot.cs

38 lines
874 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PageSpot : MonoBehaviour
{
[SerializeField] GameObject mTplSpot;
private Transform mCtn;
private List<GameObject> mLightSpots;
private void Awake()
{
mCtn = transform;
}
public void Init(int pTotalCount)
{
mLightSpots = new List<GameObject>();
for (int i = 0; i < pTotalCount; i++)
{
GameObject tSpot = Instantiate(mTplSpot, mCtn);
tSpot.SetActive(true);
tSpot.transform.localScale = Vector3.one;
mLightSpots.Add(tSpot.transform.GetChild(0).gameObject);
}
}
public void SetPageIndex(int pCurrentIndex)
{
for(int i = 0; i < mLightSpots.Count; i++)
{
mLightSpots[i].SetActive(pCurrentIndex == i);
}
}
}