Browser.OpenFile C# (CSharp) Method

OpenFile() public method

public OpenFile ( String mainFolder ) : void
mainFolder String
return void
    public void OpenFile(String mainFolder)
    {
        if(Directory.Exists(mainFolder))
        {
            WindowOpen = true;
            WinType = WindowType.Open;
            DragStat.Dragging = false;    // Ensure nothing is being draged.

            MainFolder = mainFolder; // example: Application.dataPath/Saves;
            GetAllSubDirectoriesAndFiles( MainFolder );

            AddWidth();
            AddScrollPosition(0);
            AddPath(MainFolder, 0);
        }
        else
        {
            if(File.Exists(mainFolder)) Debug.LogError("I need a main directory, not a file!");
            else Debug.LogError("I need a path for a main directory that actually exists!");
        }
    }

Usage Example

Beispiel #1
0
 private void GUIFile()
 {
     if (bShowFileButton == false)
     {
         if (GUILayout.Button("[+]File", skin.customStyles[1]))
         {
             bShowFileButton = true;
         }
     }
     else
     {
         if (GUILayout.Button("[-]File", skin.customStyles[1]))
         {
             bShowFileButton = false;
         }
     }
     if (bShowFileButton)
     {
         //GUILayout.BeginVertical(skin.customStyles[0]);
         GUILayout.BeginHorizontal();
         if (GUILayout.Button("New"))
         {
             curPath = "";
             viewer.Clear();
         }
         if (GUILayout.Button("Load"))
         {
             browser.OpenFile(Application.persistentDataPath, LoadModel);
         }
         GUILayout.EndHorizontal();
         GUILayout.BeginHorizontal();
         if (GUILayout.Button("Save"))
         {
             if (curPath != "")
             {
                 SaveModel(curPath);
             }
             else
             {
                 browser.SaveFile(Application.persistentDataPath, Application.persistentDataPath, SaveModel);
             }
         }
         if (GUILayout.Button("Save As"))
         {
             browser.SaveFile(Application.persistentDataPath, Application.persistentDataPath, SaveModel);
         }
         GUILayout.EndHorizontal();
         //GUILayout.BeginVertical();
     }
 }