1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- using UnityEngine;
- using System.Collections;
- public class ScrollLongRectBar : MonoBehaviour {
- public ScrollPage mScrollPage;
- private GameObject mPreSelect;
- private GameObject mPreDot;
- private int mPageCount;
- private int mSelectIndex;
- private GameObject mSelectItem;
- // Use this for initialization
- void Awake() {
- mPreSelect = Gow.c(gameObject).Find("select");
- mPreDot = Gow.c(gameObject).Find("dot");
- Gow.c(gameObject.transform.parent.gameObject ).PostPrefab(mPreSelect );
- Gow.c(gameObject.transform.parent.gameObject ).PostPrefab(mPreDot );
- mScrollPage.OnPageChanged += OnPageChange;
- mScrollPage.OnPageStart += OnPageStart;
- }
- void OnPageStart(int selectIndex ){
- mPageCount = mScrollPage.GetPageCount();
- mSelectIndex = 0;
- mSelectItem = Tools.createGameObjectTr(mPreSelect, gameObject );
- mSelectItem.SetActive(true);
- for (int i = 1; i < mPageCount; i++){
- GameObject pageItem = Tools.createGameObjectTr(mPreDot, gameObject );
- pageItem.SetActive(true );
- }
- OnPageChange(selectIndex );
- }
- void OnPageChange(int selectIndex ){
- //Debug.LogWarning("new index is " + selectIndex );
- if (selectIndex == mSelectIndex ){
- return;
- }
- mSelectIndex = selectIndex;
- mSelectItem.transform.SetSiblingIndex(mSelectIndex );
- }
-
- }
|