public void ReadContent(string catalog) { Panel_Catalog.DOFade(0, 1).OnComplete(() => Panel_Catalog.blocksRaycasts = false); var contentDict = PlayerManager.Instance.GetRecordContent(_isClear, _currentCatalogType, catalog); int maxPage = Mathf.Max(contentDict.Keys.Max(), 1); if ((maxPage % 2) != 2) { maxPage++; } FirstPage.SetText(GetContent(contentDict, 1)); for (int i = 2; i <= maxPage;) { var frontContent = GetContent(contentDict, i); var backContent = GetContent(contentDict, i + 1); CreatePage(frontContent, backContent); i += 2; } BookPro.CurrentPaper = 1; BookPro.UpdatePages(); }
private IEnumerator InitBookInspector(string[] files) { book.ClearPapers(); progressBox.SetActive(true); progressSlider.value = 0f; float max = files.Length; List <GameObject> list = new List <GameObject>(2); for (int i = 0; i < max; i++) { bool right = list.Count == 1 ? true : false; BookModel.PageInfo info = new BookModel.PageInfo { image = files[i] }; PageParts page = CreatePage(info, right); list.Add(page.gameObject); if (list.Count > 1) { book.AddPaper(list[0], list[1]); list.Clear(); } progressSlider.value = i / max; yield return(null); } ZLog.Log("look book that paper count = " + book.papers.Count + "; files num = " + max); book.CurrentPaper = 1; book.UpdatePages(); book.StartFlippingPaper = 0; book.EndFlippingPaper = book.papers.Count - 1; yield return(null); progressBox.SetActive(false); eventBox.SetActive(true); }
private Paper GetPaper(GameObject frontPage, GameObject backPage) { Paper newPaper = new Paper(); newPaper.Front = frontPage; newPaper.Back = backPage; Paper[] papers = new Paper[bookCurlWrapper.papers.Length + 1]; for (int i = 0; i < bookCurlWrapper.papers.Length; i++) { papers[i] = bookCurlWrapper.papers[i]; } papers[papers.Length - 1] = newPaper; bookCurlWrapper.papers = papers; bookCurlWrapper.EndFlippingPaper = bookCurlWrapper.papers.Length - 1; bookCurlWrapper.UpdatePages(); return(newPaper); }
public void AddPaper(BookPro book) { GameObject frontPage = Instantiate(FrontPagePrefab); GameObject backPage = Instantiate(BackPagePrefab); frontPage.transform.SetParent(book.transform, false); backPage.transform.SetParent(book.transform, false); Paper newPaper = new Paper(); newPaper.Front = frontPage; newPaper.Back = backPage; Paper[] papers = new Paper[book.papers.Length + 1]; for (int i = 0; i < book.papers.Length; i++) { papers[i] = book.papers[i]; } papers[papers.Length - 1] = newPaper; book.papers = papers; //update the flipping range to contain the new added paper book.EndFlippingPaper = book.papers.Length - 1; book.UpdatePages(); }