private void FlushPage(UIPageItem item, int pNum) { if (0 < pNum && pNum <= _maxPageNum) //MaxPageNum是最后一页,所以pNum < MaxPageNum条件不能刷新最后一页,需要 <= { item.Flush(_texList[pNum - 1]); } }
private RectTransform SetPage(string pageName, out UIPageItem pageItem) { RectTransform rectPage = _bookRect.Find(pageName).GetComponent <RectTransform>(); pageItem = Instantiate(_tplPage, rectPage.transform); pageItem.gameObject.SetActive(true); pageItem.name = TplPage; return(rectPage); }
/// <summary> /// 得到UI组件 /// </summary> protected override void GetUIComponent() { base.GetUIComponent(); Button_Close = GetUI <Button>("Button_Close"); Button_Catalog = GetUI <Button>("Button_Catalog"); BookPro = GetUI <BookPro>("BookPro"); AutoFlip = GetUI <AutoFlip>("BookPro"); FirstPage = GetUI <UIPageItem>("FirstPage"); Button_LeftPage = GetUI <Button>("Button_LeftPage"); Button_RigthPage = GetUI <Button>("Button_RigthPage"); Toggle_CatalogPeople = GetUI <Toggle>("Toggle_CatalogPeople"); Toggle_CatalogThing = GetUI <Toggle>("Toggle_CatalogThing"); Toggle_CatalogRecord = GetUI <Toggle>("Toggle_CatalogRecord"); Panel_Catalog = GetUI <CanvasGroup>("Panel_Catalog"); }
private Texture[] _texList = null; //纹理资源列表 #endregion #region Sys private void Awake() { _bookRect = transform.Find("Adapter/uiTurningPage").GetComponent <RectTransform>(); #region EventTrigger EventTrigger et = _bookRect.gameObject.AddComponent <EventTrigger>(); EventTrigger.Entry entry = null; entry = new EventTrigger.Entry(); entry.eventID = EventTriggerType.BeginDrag; entry.callback.AddListener(OnBeginDragBook); et.triggers.Add(entry); entry = new EventTrigger.Entry(); entry.eventID = EventTriggerType.Drag; entry.callback.AddListener(OnDragBook); et.triggers.Add(entry); entry = new EventTrigger.Entry(); entry.eventID = EventTriggerType.EndDrag; entry.callback.AddListener(OnEndDragBook); et.triggers.Add(entry); #endregion CurrMask = _bookRect.Find("mask").GetComponent <RectTransform>(); CurrMask.pivot = new Vector2(1, 0.5f); _tplPage = _bookRect.Find(TplPage).gameObject.AddComponent <UIPageItem>(); _tplPage.gameObject.SetActive(false); CurrPage = SetPage("curr", out CurrPageItem); NextPage = SetPage("next", out NextPageItem); TempPage = SetPage("temp", out TempPageItem); ActiveGOSome(false); ActiveGOTemp(false); _tranTween = _bookRect.Find("goTween").GetComponent <RectTransform>(); _txtPageNum = transform.Find("Adapter/txtPageNum").GetComponent <Text>(); _btnBF = transform.Find("Adapter/btn/btnBF").GetComponent <Button>(); _btnBF.onClick.AddListener(OnClickBtnBF); _btnZT = transform.Find("Adapter/btn/btnZT").GetComponent <Button>(); _btnZT.onClick.AddListener(OnClickBtnZT); _btnBack = transform.Find("Adapter/btnBack").GetComponent <Button>(); _btnBack.onClick.AddListener(OnClickBtnBC); //Data if (isLandScape) { AdapterUtils.Instance.SetHorizontal(transform); _rotQuaternion = Quaternion.identity * Quaternion.Euler(0, 0, -90); } else { AdapterUtils.Instance.SetVertical(transform); _rotQuaternion = Quaternion.identity; } _bookSize = _bookRect.rect.size; _globalZeroPos = Local2Global(Vector3.zero); //Tween _tweenTime = 0.5f; //需计算的Tween时间 _isTweening = false; _isReachRatio = false; FlushBtnAutoPlay(IsAutoPlay); LoadTextures(); Init(); }