コード例 #1
0
        public void DoUpdate()
        {
            if (m_RectTransform.sizeDelta.x != m_LeftPanel.sizeDelta.x - 24.0f)
            {
                m_RectTransform.sizeDelta = new Vector2(m_LeftPanel.sizeDelta.x - 24.0f, m_RectTransform.sizeDelta.y);
            }

            if (!m_IsLoaded || !m_ViewerLeftPanel.IsOpened)
            {
                if (!m_ViewerLeftPanel.IsOpened)
                {
                    m_UpdateFramesDelay = 2;
                }
                return;
            }

            if (m_UpdateFramesDelay > 0)
            {
                --m_UpdateFramesDelay;
                return;
            }

            PDFPageRange pageRange = GetVisiblePageRange();

            if (!Equals(pageRange, m_CurrentPageRange))
            {
                PDFPageRange.UpdatePageAgainstRanges(m_CurrentPageRange, pageRange, m_Document, m_PageTextureHolders, null, 0.25f, null, m_PDFViewer.GetCachedNormalPageSizes());

                m_CurrentPageRange = pageRange;
            }
        }
コード例 #2
0
        public void DoOnEnable()
        {
            if (m_PDFViewer == null)
            {
                m_PDFViewer = GetComponentInParent <PDFViewer>();
            }
            if (m_RectTransform == null)
            {
                m_RectTransform = transform as RectTransform;
            }
            if (m_LeftPanel == null)
            {
                m_LeftPanel = transform.parent as RectTransform;
            }
            if (m_ViewerLeftPanel == null)
            {
                m_ViewerLeftPanel = m_LeftPanel.GetComponent <PDFViewerLeftPanel>();
            }
            if (m_CurrentPageRange == null)
            {
                m_CurrentPageRange = new PDFPageRange();
            }

            if (!m_IsLoaded &&
                m_PDFViewer.Document != null &&
                m_PDFViewer.Document.IsValid)
            {
                OnDocumentLoaded(m_PDFViewer.Document);
            }

            m_ThumbnailItemPrefab.gameObject.SetActive(false);
        }
コード例 #3
0
ファイル: PDFThumbnailsViewer.cs プロジェクト: kimch2/Unity-1
        private PDFPageRange GetVisiblePageRange()
        {
            PDFPageRange pageRange = new PDFPageRange();

            int c = m_ThumbnailsContainer.childCount - 1;

            for (int i = 0; i < c; ++i)
            {
                if (PDFInternalUtils.CalculateRectTransformIntersectArea(m_ThumbnailsContainer.GetChild(i + 1) as RectTransform, m_RectTransform) > 0.0f)
                {
                    if (pageRange.m_From == -1)
                    {
                        pageRange.m_From = i;
                    }
                    else
                    {
                        pageRange.m_To = i + 1;
                    }
                }
                else if (pageRange.m_From != -1)
                {
                    break;
                }
            }

            if (pageRange.m_From != -1 && pageRange.m_To == -1)
            {
                pageRange.m_To = pageRange.m_From + 1;
            }

            return(pageRange);
        }
コード例 #4
0
        public void OnDocumentLoaded(PDFDocument document)
        {
            if (!m_IsLoaded && gameObject.activeInHierarchy)
            {
                m_Document = document;

                int c = m_Document.GetPageCount();

                m_PageTextureHolders = new PDFPageTextureHolder[c];
                m_ThumbnailList      = new List <PDFThumbnailItem>();

                int currentPage = m_PDFViewer.CurrentPageIndex;

                m_ThumbnailItemPrefab.gameObject.SetActive(false);

                for (int i = 0; i < c; ++i)
                {
                    PDFThumbnailItem item = null;

                    item = ((GameObject)Instantiate(m_ThumbnailItemPrefab.gameObject)).GetComponent <PDFThumbnailItem>();
                    item.transform.SetParent(m_ThumbnailItemPrefab.transform.parent, false);
                    item.gameObject.SetActive(true);

                    item.m_Highlighted.gameObject.SetActive(false);
                    item.m_PageIndexLabel.text = (i + 1).ToString();

                    m_ThumbnailList.Add(item);

                    m_PageTextureHolders[i]             = new PDFPageTextureHolder();
                    m_PageTextureHolders[i].m_PageIndex = i;
                    m_PageTextureHolders[i].m_Page      = item.m_PageThumbnailRawImage.gameObject;
                    m_PageTextureHolders[i].m_PDFViewer = m_PDFViewer;
                    m_PageTextureHolders[i].Texture     = null;
                }

                if (currentPage >= 0 && currentPage < m_PDFViewer.Document.GetPageCount())
                {
                    m_HighlightedItem = m_ThumbnailList[currentPage];
                    m_HighlightedItem.m_Highlighted.gameObject.SetActive(true);
                }

                m_CurrentPageRange = new PDFPageRange();

                m_UpdateFramesDelay = 2;
                m_IsLoaded          = true;
            }
        }
コード例 #5
0
        private PDFPageRange GetVisiblePageRange()
        {
            PDFPageRange pageRange = new PDFPageRange();

            int c = m_ThumbnailsContainer.childCount - 1;

            for (int i = 0; i < c; ++i)
            {
                RectTransform rt = m_ThumbnailsContainer.GetChild(i + 1) as RectTransform;

                Rect pageRect     = new Rect(-m_ThumbnailsContainer.anchoredPosition - rt.anchoredPosition, rt.rect.size);
                Rect viewportRect = new Rect(new Vector2(0.0f, (transform as RectTransform).rect.size.y * 0.5f), (transform as RectTransform).rect.size);

                pageRect.position     = Vector2.zero;
                viewportRect.position = Vector2.zero;

                pageRect.center     = -m_ThumbnailsContainer.anchoredPosition - rt.anchoredPosition;
                viewportRect.center = new Vector2(0.0f, (transform as RectTransform).rect.size.y * 0.5f);

                if (Intersect(pageRect, viewportRect))

                {
                    if (pageRange.m_From == -1)
                    {
                        pageRange.m_From = i;
                    }
                    else
                    {
                        pageRange.m_To = i + 1;
                    }
                }
                else if (pageRange.m_From != -1)
                {
                    break;
                }
            }

            if (pageRange.m_From != -1 && pageRange.m_To == -1)
            {
                pageRange.m_To = pageRange.m_From + 1;
            }

            return(pageRange);
        }