public int LoadBoardsAndReturnTheNumberOfBoards() { string BoardsDirectory = Application.persistentDataPath + "/savedboards/"; if (!Directory.Exists(BoardsDirectory)) { Directory.CreateDirectory(BoardsDirectory); } string[] files = Directory.GetFiles(BoardsDirectory); // make sure they're .tungboard files List <string> boardpaths = new List <string>(); foreach (string file in files) { if (file.Substring(file.Length - 10) == ".tungboard") { boardpaths.Add(file); } } for (int i = 0; i < boardpaths.Count; i++) { GameObject penis = Instantiate(SavedBoardPrefab, Parent); FileInfo penisinfo = new FileInfo(boardpaths[i]); UISavedBoard v****a = penis.GetComponent <UISavedBoard>(); v****a.FilePath = boardpaths[i]; v****a.Title.text = Path.GetFileNameWithoutExtension(boardpaths[i]); v****a.SetPosition(i); // new method of setting position v****a.Info.text = penisinfo.Length.ToString() + " bytes" // get file size ; // + " | " + penisinfo.LastAccessTime.ToString(); // get the local time of the last time the save was modified UISavedBoards.Add(v****a); } Debug.Log(boardpaths.Count.ToString() + " saved boards"); return(boardpaths.Count); }
public void ChangeSelectedBoard(UISavedBoard selected) { LoadButton.interactable = true; DeleteButton.interactable = true; RenameButton.interactable = true; // double click functionality if (selected == SelectedBoard) { Load(); return; } SelectedBoard = selected; // change its color, change all the other colors back to default foreach (UISavedBoard save in UISavedBoards) { save.image.color = deselectedcolor; } selected.image.color = selectedcolor; }