// Setup path, load and save file text private void SetupTextLabels() { // Find the path and file label (path label optional in Portrait UI) GameObject pathLabel = GameObject.Find("PathLabel"); GameObject fileLabel = FileBrowserUtilities.FindGameObjectOrError("FileLabel"); // Find pathText game object to update path on clicks _pathText = FileBrowserUtilities.FindGameObjectOrError("PathText"); // Find loadText game object to update load file text on clicks _loadFileText = FileBrowserUtilities.FindGameObjectOrError("LoadFileText"); // Find saveFileText game object to update save file text // and hook up onValueChanged listener to check the name using CheckValidFileName method _saveFileText = FileBrowserUtilities.FindGameObjectOrError("SaveFileText"); _saveFileTextInputFile = _saveFileText.GetComponent<InputField>(); _saveFileTextInputFile.onValueChanged.AddListener(_fileBrowser.CheckValidFileName); PanelTextFontSize = Screen.height / 40; // Set font size for labels and texts if (pathLabel != null) { pathLabel.GetComponent<Text>().fontSize = PanelTextFontSize; } fileLabel.GetComponent<Text>().fontSize = PanelTextFontSize; _pathText.GetComponent<Text>().fontSize = PanelTextFontSize; _loadFileText.GetComponent<Text>().fontSize = PanelTextFontSize; foreach (Text textComponent in _saveFileText.GetComponentsInChildren<Text>()) { textComponent.fontSize = PanelTextFontSize; } }
// Setup click listeners for buttons private void SetupClickListeners() { // Hook up Directory Navigation methods to Directory Navigation Buttons FileBrowserUtilities.FindButtonAndAddOnClickListener("DirectoryBackButton", _fileBrowser.DirectoryBackward); FileBrowserUtilities.FindButtonAndAddOnClickListener("DirectoryForwardButton", _fileBrowser.DirectoryForward); FileBrowserUtilities.FindButtonAndAddOnClickListener("DirectoryUpButton", _fileBrowser.DirectoryUp); // Hook up CloseFileBrowser method to CloseFileBrowserButton FileBrowserUtilities.FindButtonAndAddOnClickListener("CloseFileBrowserButton", _fileBrowser.CloseFileBrowser); // Hook up SelectFile method to SelectFileButton _selectFileButton = FileBrowserUtilities.FindButtonAndAddOnClickListener("SelectFileButton", _fileBrowser.SelectFile); }
// Setup search filter private void SetupSearchInputField() { // Find search input field and get input field component // and hook up onValueChanged listener to update search results on value change _searchInputField = FileBrowserUtilities.FindGameObjectOrError("SearchInputField").GetComponent<InputField>(); foreach (Text textComponent in _searchInputField.GetComponentsInChildren<Text>()) { textComponent.fontSize = PanelTextFontSize; } _searchInputField.onValueChanged.AddListener(_fileBrowser.UpdateSearchFilter); }
// Setup parents object to hold directories and files (implemented in Landscape and Portrait version) private void SetupParents() { // Find directories parent to group directory buttons DirectoriesParent = FileBrowserUtilities.FindGameObjectOrError("Directories"); // Find files parent to group file buttons FilesParent = FileBrowserUtilities.FindGameObjectOrError("Files"); // Set the button height ItemButtonHeight = Screen.height / 10; SetButtonParentHeight(DirectoriesParent, ItemButtonHeight); SetButtonParentHeight(FilesParent, ItemButtonHeight); // Set the panel color FileBrowserUtilities.FindGameObjectOrError("DirectoryPanel").GetComponent<Image>().color = DirectoryPanelColor; FileBrowserUtilities.FindGameObjectOrError("FilePanel").GetComponent<Image>().color = FilePanelColor; }