public SaveFile ( String FilePath, String mainFolder ) : void | ||
FilePath | String | |
mainFolder | String | |
return | void |
public void SaveFile(String FilePath, String mainFolder)
{
if(Directory.Exists(mainFolder))
{
if(File.Exists(FilePath) || Directory.Exists(FilePath))
{
WindowOpen = true;
WinType = WindowType.Save;
DragStat.Dragging = false; // Ensure nothing is being draged.
FileToSave = FilePath;
MainFolder = mainFolder; // example: Application.dataPath/Saves;
GetAllSubDirectoriesAndFiles( MainFolder );
AddWidth();
AddScrollPosition(0);
AddPath(MainFolder, 0);
}
else Debug.LogError("I need a path for a temporary save file that actually exists!");
}
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!");
}
}
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(); } }