This is an unity built in file explorer I made for my game, it has basic features like changing path, select files, shortcuts and filters
- First of all, download the package zip file and extract it
- Open the unity package manager andselect the option "Add project from disk", then select the package.json file from the unzipped folder
- Wait until the installation is completed
- Now that we have installed the package in the project let's drag the FileExplorer prefab from the Package folder
- Now add the camera to the canvas and add the UI Event system
- Create an initializer script:
public class FileExplorerTest : MonoBehaviour { void Start() { FileExplorerManager.Instance.Hide(); //IMPORTANT (Initialize the instance, the gameobject must be active) FileExplorerManager.Instance.Show(); //Call this when you want it to pop up } }
- Everything should work!
Create a script and add a function to handle the selected file, you can access the file path and name
public void HandleSelectedFile()
{
Debug.Log("A file has been selected! " + FileExplorerManager.Instance.GetSelectedFile().filePath);
}
Add the function to the event system
To costumize the explorer settings go to the FileExplorer gameobject
This array defines all the allowed extensions, the other files will be ignored, leane the array blank to allow all files extensions
A boolean shows/hides the close button (in case a user MUST select a file)
In the FileExplorer gameobject you should be able to find the FileIcons script where you can decide the icons