Use a universally supported library for file picking

This commit is contained in:
2025-08-26 14:10:27 -07:00
parent 36b2b5cd36
commit 996ea62161
160 changed files with 23680 additions and 3728 deletions

View File

@@ -18,11 +18,6 @@ public class IconMarketplaceManager : MonoBehaviour
void Start()
{
downloadButton.onClick.AddListener(() => SwitchPanel(1));
#if !UNITY_STANDALONE_OSX && !UNITY_STANDALONE_WIN && !UNITY_STANDALONE_LINUX && !UNITY_EDITOR
uploadButton.interactable = false;
uploadButton.transform.GetChild(0).transform.localPosition = new Vector3(0, 10, 0);
uploadButton.transform.GetChild(1).GetComponent<TMP_Text>().text = "Unsupported platform";
#else
if (BazookaManager.Instance.GetAccountID() != null && BazookaManager.Instance.GetAccountName() != null && BazookaManager.Instance.GetAccountSession() != null)
{
uploadButton.onClick.AddListener(() => SwitchPanel(2));
@@ -33,7 +28,6 @@ public class IconMarketplaceManager : MonoBehaviour
uploadButton.transform.GetChild(0).transform.localPosition = new Vector3(0, 10, 0);
uploadButton.transform.GetChild(1).GetComponent<TMP_Text>().text = "Not logged in to an account";
}
#endif
SwitchPanel(0);
}

View File

@@ -1,7 +1,8 @@
using System;
using System.IO;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
using SFB;
using SimpleFileBrowser;
using TMPro;
using UnityEngine;
using UnityEngine.Networking;
@@ -42,9 +43,9 @@ public class IconMarketplaceUploadIcon : MonoBehaviour
UploadIcon();
}
});
selectButton.onClick.AddListener(() =>
selectButton.onClick.AddListener(async () =>
{
string path = OpenFilePicker();
string path = await OpenFilePicker();
if (path == null) return;
byte[] fileContent;
try
@@ -68,17 +69,20 @@ public class IconMarketplaceUploadIcon : MonoBehaviour
});
}
string OpenFilePicker()
async Task<string> OpenFilePicker()
{
var filters = new[] {
new ExtensionFilter("Image Files", "png"),
};
var paths = StandaloneFileBrowser.OpenFilePanel("Select an icon file", "", filters, false);
if (paths.Length > 0 && !string.IsNullOrEmpty(paths[0]))
{
return paths[0];
}
return null;
FileBrowser.SetFilters(true, new FileBrowser.Filter("Images", ".png"));
var tcs = new TaskCompletionSource<string>();
FileBrowser.ShowLoadDialog(
(paths) => tcs.SetResult(paths.Length > 0 ? paths[0] : null),
() => tcs.SetResult(null),
FileBrowser.PickMode.Files,
false
);
return await tcs.Task;
}
async void UploadIcon()