Exemplo n.º 1
0
        public void ShowPicBook()
        {
            VideoScrollView.gameObject.SetActive(false);
            AudioScrollView.gameObject.SetActive(false);
            PicBookScrollView.gameObject.SetActive(true);
            if (PicBookScrollView.Find("Viewport").Find("Content").childCount > 0)
            {
                NoData.gameObject.SetActive(false);
                return;
            }

            // 创建视频Item
            var index = PlayerPrefsUtil.GetBoxMonthIndex();
            // 取出该盒子下的绘本列表
            var total = PlayerPrefsUtil.ContentModel.boxList[index].picBookList;

            for (int i = 0; i < total.Count; i++)
            {
                var model = total[i];

                if (isCotainCheck(model))
                {
                    picBookList.Add(model);
                }
            }

            DoCreatePicBookItem(picBookList);
            // 填充绘本列表数据
        }
Exemplo n.º 2
0
        private void DoCreatePicBookItem(List <DayActionModel> picBookModel)
        {
            int row    = picBookModel.Count / 3;
            int column = picBookModel.Count % 3;

            for (int i = 0; i < row; i++)
            {
                Transform itemPickBookGroup = mResLoader.LoadSync <GameObject>("ItemPicBookGroup")
                                              .Instantiate()
                                              .transform
                                              .LocalIdentity()
                                              .Parent(PicBookScrollView.Find("Viewport").Find("Content"))
                                              .LocalScale(1, 1, 1)
                                              .Show();
                for (int j = 0; j < 3; j++)
                {
                    int        index        = (i * 3 + j);
                    var        bookBean     = picBookModel[index];
                    GameObject itemPickBook = itemPickBookGroup.transform.Find(j.ToString()).gameObject;
                    itemPickBook.name = index.ToString();
                    var image = itemPickBook.transform.Find("MaskImage").Find("Image").GetComponent <Image>();
                    ImageDownloadUtils.Instance.SetAsyncImage(bookBean.thumbnailPath, image);
                    var name = itemPickBook.transform.Find("ImageBottom/Text").GetComponent <Text>();
                    name.text = bookBean.name;
                    itemPickBook.transform.GetComponent <Button>().onClick.RemoveAllListeners();
                    itemPickBook.transform.GetComponent <Button>().onClick
                    .AddListener(delegate { OnClickPicBook(itemPickBook, bookBean); });
                }
            }

            if (column == 1)
            {
                Transform itemPickBookGroup = mResLoader.LoadSync <GameObject>("ItemPicBookGroup")
                                              .Instantiate()
                                              .transform
                                              .LocalIdentity()
                                              .Parent(PicBookScrollView.Find("Viewport").Find("Content"))
                                              .LocalScale(1, 1, 1)
                                              .Show();            int index = row * 3;
                var        bookBean     = picBookModel[index];
                GameObject itemPickBook = itemPickBookGroup.transform.Find(1.ToString()).gameObject;
                itemPickBook.name = index.ToString();
                var image = itemPickBook.transform.Find("MaskImage").Find("Image").GetComponent <Image>();
                Debug.Log("image ===" + bookBean.thumbnailPath);
                ImageDownloadUtils.Instance.SetAsyncImage(bookBean.thumbnailPath, image);
                var name = itemPickBook.transform.Find("ImageBottom/Text").GetComponent <Text>();
                name.text = bookBean.name;
                itemPickBook.transform.GetComponent <Button>().onClick.RemoveAllListeners();
                itemPickBook.transform.GetComponent <Button>().onClick
                .AddListener(delegate { OnClickPicBook(itemPickBook, bookBean); });
                GameObject itemPickBook0 = itemPickBookGroup.transform.Find(0.ToString()).gameObject;
                itemPickBook0.SetActive(false);
                GameObject itemPickBook2 = itemPickBookGroup.transform.Find(2.ToString()).gameObject;
                itemPickBook2.SetActive(false);
            }
            else if (column == 2)
            {
                Transform itemPickBookGroup = mResLoader.LoadSync <GameObject>("ItemPicBookGroup")
                                              .Instantiate()
                                              .transform
                                              .LocalIdentity()
                                              .Parent(PicBookScrollView.Find("Viewport").Find("Content"))
                                              .LocalScale(1, 1, 1)
                                              .Show();            int index = row * 3;
                var        bookBean     = picBookModel[index];
                GameObject itemPickBook = itemPickBookGroup.transform.Find(0.ToString()).gameObject;
                itemPickBook.name = index.ToString();
                var image = itemPickBook.transform.Find("MaskImage").Find("Image").GetComponent <Image>();
                Debug.Log("image ===" + image);
                ImageDownloadUtils.Instance.SetAsyncImage(bookBean.thumbnailPath, image);
                var name = itemPickBook.transform.Find("ImageBottom/Text").GetComponent <Text>();
                name.text = bookBean.name;
                itemPickBook.transform.GetComponent <Button>().onClick.RemoveAllListeners();
                itemPickBook.transform.GetComponent <Button>().onClick
                .AddListener(delegate { OnClickPicBook(itemPickBook, bookBean); });
                GameObject itemPickBook0 = itemPickBookGroup.transform.Find(2.ToString()).gameObject;
                itemPickBook0.SetActive(false);

                GameObject itemPickBook2 = itemPickBookGroup.transform.Find(1.ToString()).gameObject;
                index              = row * 3 + 1;
                bookBean           = picBookModel[index];
                itemPickBook2.name = index.ToString();
                var image1 = itemPickBook2.transform.Find("MaskImage").Find("Image").GetComponent <Image>();
                ImageDownloadUtils.Instance.SetAsyncImage(bookBean.thumbnailPath, image1);
                itemPickBook2.transform.Find("ImageBottom/Text").GetComponent <Text>().text = bookBean.name;
                itemPickBook2.transform.GetComponent <Button>().onClick.RemoveAllListeners();
                itemPickBook2.transform.GetComponent <Button>().onClick
                .AddListener(delegate { OnClickPicBook(itemPickBook, bookBean); });
            }
            if (picBookModel.Count == 0)
            {
                NoData.gameObject.SetActive(true);
                NoData.transform.Find("Text").GetComponent <Text>().text = "暂无已解锁绘本哦~";
            }
            else
            {
                NoData.gameObject.SetActive(false);
            }
        }