Esempio n. 1
0
        /// <summary>
        /// Initialize the box
        /// </summary>
        /// <param name="scrollingList">The list which this box belongs to</param>
        /// <param name="listPositionCtrl">The position controller of this box</param>
        /// <param name="listContentManager">The content controller</param>
        /// <param name="listBoxID">The ID of this box</param>
        public void Initialize(
            CircularScrollingList scrollingList,
            ListPositionCtrl listPositionCtrl,
            ListContentManager listContentManager,
            int listBoxID)
        {
            this.scrollingList = scrollingList;
            this.listBoxID     = listBoxID;

            _listSetting    = scrollingList.setting;
            _positionCtrl   = listPositionCtrl;
            _contentManager = listContentManager;
            _listBoxes      = scrollingList.listBoxes;

            InitializePosition();
            InitializeBoxDependency();
            InitializeContent();
            AddClickEvent();
        }
        /// <summary>
        /// Initialize the related list components
        /// </summary>
        private void InitializeListComponents()
        {
            _listPositionCtrl =
                new ListPositionCtrl(
                    _setting, _rectTransform, _canvasRefCamera, _listBoxes);
            _listContentManager =
                new ListContentManager(
                    _setting, _listBank, _listBoxes.Count);

            if (_setting.centerSelectedBox)
            {
                _setting.onBoxClick.AddListener(SelectContentID);
            }

            for (var i = 0; i < _listBoxes.Count; ++i)
            {
                _listBoxes[i].Initialize(
                    this, _listPositionCtrl, _listContentManager, i);
            }

            _hasNoContent = _listBank.GetListLength() == 0;
        }