// Core public void RefreshButtons() { CancelCurrentThumbnails(); MainPanel.sizeDelta = Vector2.zero; // Destroy previous buttons for (int i = 0; i < Buttons.Count; i++) { Buttons[i].gameObject.SetActive(false); DestroyImmediate(Buttons[i].gameObject); } // Clear List Buttons.Clear(); DirectoryInfo Dir = _FB.GetCurrentDirectory(); if (Dir != null) { CurrentAdress.text = Dir.FullName; } else { CurrentAdress.text = string.Empty; } /* * bool isFavorite = false; * for (int i = 0; i < Favorites.Count; i++) * { * RectTransform _CurrentRect = Favorites[i].gameObject.GetComponent<RectTransform>(); * * if (_CurrentRect.FindChild("Name").gameObject.GetComponent<Text>().text == CurrentAdress.text) * { * isFavorite = true; * break; * } * } * * if (isFavorite) * { * FavoriteImage.color = new Color(1, 1, 0, 1); * } * else * { * FavoriteImage.color = new Color(1, 1, 1, 1); * } */ // Retrieve sub directories DirectoryInfo[] _childs = _FB.GetChildDirectories(); // Add a button for each folder for (int i = 0; i < _childs.Length; i++) { // Dissociate folders from drives if (_childs[i].Parent != null) { AddButton(_childs[i].Name, ButtonType.Folder); } else { AddButton(_childs[i].Name, ButtonType.Drive); } } if (!FolderOnly.isOn) { // Retrieve files FileInfo[] _files = _FB.GetFiles(); // Add a button for each file for (int i = 0; i < _files.Length; i++) { AddButton(_files[i].Name, ButtonType.File); } lock (_ThumbnailsFiles) { _ThumbnailsFiles = _files; } GenerateNewThumbnails = true; StartCoroutine(WaitForThumbnails()); } CheckButtonsVisibility(); }
private readonly Dictionary <GameObject, ResultBean> allGoK_ResultBeanV = new Dictionary <GameObject, ResultBean>(); // 以 中间每个 Item 为Key,以图片结果为 Value private void RefreshMiddleContent() // 刷新中间的内容 { //—————————————————— 1. 先清除原来的 —————————————————— btnDaoRu.interactable = false; // 不能导入 btnGeiMing.interactable = false; go_CurrentSelect = null; input_GeiMing.text = ""; ClearAllChooseZhong(); // 清除所有选中的 Ctrl_Coroutine.Instance.StopAllCoroutines(); // 关闭所有协程 for (int i = 0; i < l_MiddleItems.Count; i++) // 删除原来生成的 { Object.Destroy(l_MiddleItems[i].gameObject); } l_MiddleItems.Clear(); allGoK_ResultBeanV.Clear(); //—————————————————— 2. 判断是否桌面,如果是,再添加我的电脑—————————————————— DirectoryInfo dir = mFileBrowser.GetCurrentDirectory(); // 当前文件夹路径 if (null != dir && dir.FullName == System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop)) { AddMiddleButton(dir, MiddleButtonType.Computer); // 我的电脑 } //—————————————————— 3. 添加文件夹和文件—————————————————— DirectoryInfo[] folderList = mFileBrowser.GetChildDirectories(); // 获得所有文件夹 Ctrl_Coroutine.Instance.StartCoroutine(LoadFileAndFolder(folderList, dir)); //—————————————————— 4. 设置头部栏 历史、地址、书签—————————————————— btn_HistoryPre.interactable = mFileBrowser.GetIsHasHistoryPre; // 有没有上下历史 btn_HistoryNext.interactable = mFileBrowser.GetIsHasHistoryNext; // 设置头部栏的地址 string topPath; if (dir != null) { tx_Path.text = dir.FullName; topPath = dir.Name; l_AddressPaths[mCurrentTopIndex] = dir.FullName; Ctrl_DaoRuInfo.Instance.ShowFirstPath = dir.FullName; } else { tx_Path.text = "计算机"; topPath = "计算机"; } switch (mCurrentTopIndex) { case 0: tx_TopPath1.text = topPath; break; case 1: tx_TopPath2.text = topPath; break; case 2: tx_TopPath3.text = topPath; break; case 3: tx_TopPath4.text = topPath; break; case 4: tx_TopPath5.text = topPath; break; } // 这个路径是否书签 bool isFavorite = false; foreach (string path in Ctrl_DaoRuInfo.Instance.L_FavoritesPath) { if (tx_Path.text.Equals(path)) { isFavorite = true; break; } } toggle_Star.isOn = isFavorite; }