- Home /
[File-explorer]How Implements a crude file browser in Unity3d?
Friends , it is very good help in our progress ! Now I need your help . I am wanting to create a File - Explorer to access my sdcard directory on Android .
Because the programmer created this solution with a code that does NOT belong to MonoBehaviour class ? HOW COULD BE IMPLEMENTED ?
Code Complete ( http://wiki.unity3d.com/index.php?title=FileBrowser )
public static bool FileBrowser( ref string location, ref Vector2 directoryScroll, ref Vector2 fileScroll )
{
bool complete;
DirectoryInfo directoryInfo;
DirectoryInfo directorySelection;
FileInfo fileSelection;
int contentWidth;
// Our return state - altered by the "Select" button
complete = false;
// Get the directory info of the current location
fileSelection = new FileInfo( location );
if( (fileSelection.Attributes & FileAttributes.Directory) == FileAttributes.Directory )
{
directoryInfo = new DirectoryInfo( location );
}
else
{
directoryInfo = fileSelection.Directory;
}
if( location != "/" && GUI.Button( new Rect( 10, 20, 410, 20 ), "Up one level" ) )
{
directoryInfo = directoryInfo.Parent;
location = directoryInfo.FullName;
}
................................
Here 's how to use it , but FileBrowserWindow is not in the current context :
Code Complete ( http://wiki.unity3d.com/index.php?title=FileBrowser )
public void FileBrowserWindow( int idx )
{
if( FileBrowser( ref location, ref directoryScroll, ref fileScroll ) )
{
fileBrowser = false;
}
}
public void OnGUI()
{
if( fileBrowser )
{
GUI.Window( 0, new Rect( ( Screen.width - 430 ) / 2, ( Screen.height - 380 ) / 2, 430, 380 ), FileBrowserWindow, "Browse" );
return;
}
}
THERE'S SOMETHING MISSING DO .
PLEASE HELP ME TO DO THIS CODE WORK .
Come together to advance !
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Looping animation on rightmousebutton? 1 Answer
Hide the ImageTraget in Real world 0 Answers