Skip to content

Commit

Permalink
standalone file browser
Browse files Browse the repository at this point in the history
  • Loading branch information
pulkitgarg784 committed Apr 7, 2021
1 parent d4e8911 commit fc7af9c
Show file tree
Hide file tree
Showing 54 changed files with 3,768 additions and 10 deletions.
16 changes: 16 additions & 0 deletions .idea/.idea.Voksel/.idea/contentModel.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 53 additions & 4 deletions .idea/.idea.Voksel/.idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions Assets/Scripts/Serialization/SaveManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections;
using System.Collections.Generic;
using System.IO;
using SFB;
using UnityEditor;
using UnityEngine;
using UnityEngine.UI;
Expand All @@ -12,6 +13,8 @@ public class SaveManager : MonoBehaviour
public Transform modelHolder;
public Text projectTitle;
public GameObject saveLoadPrompt;


private void Update()
{
if (Input.GetKeyDown(KeyCode.Escape))
Expand All @@ -26,14 +29,19 @@ private void Update()

public void OnSave()
{
string path = EditorUtility.SaveFilePanel("Save as", "", "untitled", "voksel");
//string path = EditorUtility.SaveFilePanel("Save as", "", "untitled", "voksel");
string path = StandaloneFileBrowser.SaveFilePanel("Save as", "", "untitled", "voksel");
path = path.Replace("\\", "/");

SerializationManager.Save(path, saveData.current);
Debug.Log("saved");
}

public void OnLoad()
{
string path = EditorUtility.OpenFilePanel("Open Project", "", "voksel");
//string path = EditorUtility.OpenFilePanel("Open Project", "", "voksel");
string path = StandaloneFileBrowser.OpenFilePanel("Open Project", "", "voksel", false)[0];
path = path.Replace("\\", "/");
if (File.Exists(path))
{
saveData.current = (saveData) SerializationManager.Load(path);
Expand Down
1 change: 0 additions & 1 deletion Assets/Scripts/box.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ private void Start()
cubedata.position = transform.position;
cubedata.color = GetComponent<Renderer>().material.color;
saveData.current.cubes.Add(cubedata);
Debug.Log(saveData.current.cubes);
}

//assign to load event
Expand Down
7 changes: 6 additions & 1 deletion Assets/Scripts/exporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections;
using System.Collections.Generic;
using System.IO;
using SFB;
using UnityEditor;
using UnityEngine;
using UnityFBXExporter;
Expand All @@ -17,7 +18,11 @@ public void ExportFbx()
Debug.Log("trying to export");
Debug.Log(fileName.text);
Debug.Log(filePath.text);
string path = EditorUtility.SaveFilePanel("Export as FBX", "", "untitled", "fbx");
//string path = EditorUtility.SaveFilePanel("Export as FBX", "", "untitled", "fbx");
string path = StandaloneFileBrowser.SaveFilePanel("Export as FBX", "", "untitled", "fbx");
//string path = @"C:\Users\Pulkit\Desktop\untitled.fbx";
path = path.Replace("\\", "/");
Debug.Log(path);
FBXExporter.ExportGameObjToFBX(objMeshToExport, path, true, true);
Debug.Log("exported");

Expand Down
8 changes: 8 additions & 0 deletions Assets/StandaloneFileBrowser.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions Assets/StandaloneFileBrowser/IStandaloneFileBrowser.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;

namespace SFB {
public interface IStandaloneFileBrowser {
string[] OpenFilePanel(string title, string directory, ExtensionFilter[] extensions, bool multiselect);
string[] OpenFolderPanel(string title, string directory, bool multiselect);
string SaveFilePanel(string title, string directory, string defaultName, ExtensionFilter[] extensions);

void OpenFilePanelAsync(string title, string directory, ExtensionFilter[] extensions, bool multiselect, Action<string[]> cb);
void OpenFolderPanelAsync(string title, string directory, bool multiselect, Action<string[]> cb);
void SaveFilePanelAsync(string title, string directory, string defaultName, ExtensionFilter[] extensions, Action<string> cb);
}
}
12 changes: 12 additions & 0 deletions Assets/StandaloneFileBrowser/IStandaloneFileBrowser.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Assets/StandaloneFileBrowser/Plugins.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions Assets/StandaloneFileBrowser/Plugins/Linux.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions Assets/StandaloneFileBrowser/Plugins/Linux/x86_64.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Loading

0 comments on commit fc7af9c

Please sign in to comment.