Ejemplo n.º 1
0
        IEnumerator LoadDirectory(DirectoryInfo dir)
        {
            if (dir.Exists)
            {
                DirectoryInfo[] dirs = dir.GetDirectories().OrderByDescending(d => d.LastWriteTime).ToArray();
                for (int i = 0; i < items.Count; i++)
                {
                    UIImageGrid ug = items[i] as UIImageGrid;
                    if (!ug.EqualDirectory(dirs[i]))
                    {
                        ug.Load(dirs[i]);
                    }
                }
                if (items.Count < dirs.Length)
                {
                    for (int i = items.Count; i < dirs.Length; i++)
                    {
                        UIImageGrid grid = AddItem(dirs[i]);
                        if (grid != null)
                        {
                            yield return(new WaitUntil(grid.IsLoaded));

                            topPos -= grid.GetHeight() + spaceY;
                        }
                    }
                }
                topPos -= bottomRect.sizeDelta.y;
            }
            yield return(new WaitForEndOfFrame());

            Refresh();
        }
Ejemplo n.º 2
0
        public UIImageGrid AddItem(DirectoryInfo dir, int index = -1)
        {
            GameObject  obj  = Instantiate(gridPrefab, contentRect);
            UIImageGrid grid = obj.GetComponent <UIImageGrid>();

            grid.SetPosY(topPos);
            grid.Load(dir);
            grid.ItemClickedHandler = OnClickImage;
            if (index != -1)
            {
                Items.Insert(index, grid);
                obj.transform.SetSiblingIndex(index);
            }
            grid.Parent = this;
            return(grid);
        }