예제 #1
0
파일: BookPro.cs 프로젝트: xu509/BCitySign
        public void DragLeftPageToPoint(Vector3 point)
        {
            if (currentPaper <= StartFlippingPaper)
            {
                return;
            }
            pageDragging = true;
            mode         = FlipMode.LeftToRight;
            f            = point;

            UpdatePages();

            ClippingPlane.rectTransform.pivot = new Vector2(0, 0.35f);

            Right = papers[currentPaper - 1].Back.GetComponent <Image>();
            BookUtility.ShowPage(Right.gameObject);
            Right.transform.position         = LeftPageTransform.transform.position;
            Right.transform.localEulerAngles = new Vector3(0, 0, 0);
            Right.transform.SetAsFirstSibling();

            Left = papers[currentPaper - 1].Front.GetComponent <Image>();
            BookUtility.ShowPage(Left.gameObject);
            Left.gameObject.SetActive(true);
            Left.rectTransform.pivot        = new Vector2(1, 0);
            Left.transform.position         = LeftPageTransform.transform.position;
            Left.transform.localEulerAngles = new Vector3(0, 0, 0);


            if (enableShadowEffect)
            {
                ShadowLTR.gameObject.SetActive(true);
            }
            ClippingPlane.gameObject.SetActive(true);
            UpdateBookLTRToPoint(f);
        }
예제 #2
0
파일: BookPro.cs 프로젝트: xu509/BCitySign
        public void DragRightPageToPoint(Vector3 point)
        {
            if (currentPaper > EndFlippingPaper)
            {
                return;
            }

            pageDragging = true;
            mode         = FlipMode.RightToLeft;
            f            = point;

            ClippingPlane.rectTransform.pivot = new Vector2(1, 0.35f);
            currentPaper += 1;
            Debug.Log("更新当前页码索引");

            UpdatePages();

            Left = papers[currentPaper - 1].Front.GetComponent <Image>();
            BookUtility.ShowPage(Left.gameObject);
            Left.rectTransform.pivot        = new Vector2(0, 0);
            Left.transform.position         = RightPageTransform.transform.position;
            Left.transform.localEulerAngles = new Vector3(0, 0, 0);

            Right = papers[currentPaper - 1].Back.GetComponent <Image>();
            BookUtility.ShowPage(Right.gameObject);
            Right.transform.position         = RightPageTransform.transform.position;
            Right.transform.localEulerAngles = new Vector3(0, 0, 0);

            if (enableShadowEffect)
            {
                Shadow.gameObject.SetActive(true);
            }
            ClippingPlane.gameObject.SetActive(true);

            UpdateBookRTLToPoint(f);
        }
예제 #3
0
파일: BookPro.cs 프로젝트: xu509/BCitySign
        /// <summary>
        /// Update page orders
        /// This function should be called whenever the current page changed, the dragging of the page started or the page has been flipped
        /// </summary>
        public void UpdatePages()
        {
            updateButton();
            int previousPaper = pageDragging ? currentPaper - 2 : currentPaper - 1;

            //Hide all pages
            for (int i = 0; i < papers.Count; i++)
            {
                BookUtility.HidePage(papers[i].Front);
                papers[i].Front.transform.SetParent(BookPanel.transform);
                BookUtility.HidePage(papers[i].Back);
                papers[i].Back.transform.SetParent(BookPanel.transform);
            }

            if (hasTransparentPages)
            {
                //Show the back page of all previous papers
                for (int i = 0; i <= previousPaper; i++)
                {
                    BookUtility.ShowPage(papers[i].Back);
                    papers[i].Back.transform.SetParent(BookPanel.transform);
                    papers[i].Back.transform.SetSiblingIndex(i);
                    BookUtility.CopyTransform(LeftPageTransform.transform, papers[i].Back.transform);
                }

                //Show the front page of all next papers
                for (int i = papers.Count - 1; i >= currentPaper; i--)
                {
                    BookUtility.ShowPage(papers[i].Front);
                    papers[i].Front.transform.SetSiblingIndex(papers.Count - i + previousPaper);
                    BookUtility.CopyTransform(RightPageTransform.transform, papers[i].Front.transform);
                }
            }
            else
            {
                //show back of previous page only
                if (previousPaper >= 0)
                {
                    BookUtility.ShowPage(papers[previousPaper].Back);
                    //papers[previousPaper].Back.transform.SetParent(BookPanel.transform);
                    //papers[previousPaper].Back.transform.SetSiblingIndex(previousPaper);
                    BookUtility.CopyTransform(LeftPageTransform.transform, papers[previousPaper].Back.transform);
                }
                //show front of current page only
                if (currentPaper <= papers.Count - 1)
                {
                    BookUtility.ShowPage(papers[currentPaper].Front);
                    papers[currentPaper].Front.transform.SetSiblingIndex(papers.Count - currentPaper + previousPaper);
                    BookUtility.CopyTransform(RightPageTransform.transform, papers[currentPaper].Front.transform);
                }
            }
            #region Shadow Effect
            if (enableShadowEffect)
            {
                //the shadow effect enabled
                if (previousPaper >= 0)
                {
                    //has at least one previous page, then left shadow should be active
                    LeftPageShadow.gameObject.SetActive(true);
                    LeftPageShadow.transform.SetParent(papers[previousPaper].Back.transform, true);
                    LeftPageShadow.rectTransform.anchoredPosition = new Vector3();
                    LeftPageShadow.rectTransform.localRotation    = Quaternion.identity;
                }
                else
                {
                    //if no previous pages, the leftShaow should be disabled
                    LeftPageShadow.gameObject.SetActive(false);
                    LeftPageShadow.transform.SetParent(BookPanel, true);
                }

                if (currentPaper < papers.Count)
                {
                    //has at least one next page, the right shadow should be active
                    RightPageShadow.gameObject.SetActive(true);
                    RightPageShadow.transform.SetParent(papers[currentPaper].Front.transform, true);
                    RightPageShadow.rectTransform.anchoredPosition = new Vector3();
                    RightPageShadow.rectTransform.localRotation    = Quaternion.identity;
                }
                else
                {
                    //no next page, the right shadow should be diabled
                    RightPageShadow.gameObject.SetActive(false);
                    RightPageShadow.transform.SetParent(BookPanel, true);
                }
            }
            else
            {
                //Enable Shadow Effect is Unchecked, all shadow effects should be disabled
                LeftPageShadow.gameObject.SetActive(false);
                LeftPageShadow.transform.SetParent(BookPanel, true);

                RightPageShadow.gameObject.SetActive(false);
                RightPageShadow.transform.SetParent(BookPanel, true);
            }
            #endregion
        }