// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖 

using UnityEngine;
using FairyGUI;
using NBC;

namespace NBF
{
    public partial class SelectPages : GComponent
    {
        public int TotalPages { get; private set; }

        public int CurrentPage { get; private set; }

        private void OnInited()
        {
        }

        public void SetTotal(int totalPage)
        {
            TotalPages = totalPage;
            List.RemoveChildrenToPool();
            for (var i = 0; i < totalPage; i++)
            {
                List.AddItemFromPool();
            }
        }

        public void SetCurrent(int currentPage)
        {
            if (currentPage < 0 || currentPage >= TotalPages) return;
            CurrentPage = currentPage;
            List.selectedIndex = CurrentPage;
        }
    }
}