31 lines
991 B
C#
31 lines
991 B
C#
using UnityEngine;
|
|
using SFB;
|
|
|
|
public class SaveLoadManagerUI : MonoBehaviour
|
|
{
|
|
private ExtensionFilter[] extensions = new[] {
|
|
new ExtensionFilter("BlockMap Files", "blockmap"),
|
|
new ExtensionFilter("All Files", "*"),
|
|
};
|
|
|
|
public void OnSaveButtonClicked()
|
|
{
|
|
var path = StandaloneFileBrowser.SaveFilePanel("Save BlockMap", "", "MyMap", extensions);
|
|
if (!string.IsNullOrEmpty(path))
|
|
{
|
|
FindObjectOfType<EnvironmentObserver>().saveToPath(path);
|
|
Debug.Log("Successfully saved BlockMap to: " + path);
|
|
}
|
|
}
|
|
|
|
public void OnLoadButtonClicked()
|
|
{
|
|
var paths = StandaloneFileBrowser.OpenFilePanel("Open BlockMap", "", extensions, false);
|
|
if (paths != null && paths.Length > 0 && !string.IsNullOrEmpty(paths[0]))
|
|
{
|
|
FindObjectOfType<EnvironmentObserver>().loadFromPath(paths[0]);
|
|
Debug.Log("Successfully loaded BlockMap from: " + paths[0]);
|
|
}
|
|
}
|
|
}
|