Skip to content

Commit

Permalink
fix: destination folder do not exists and convert to sprite from isom…
Browse files Browse the repository at this point in the history
…etric workflow
  • Loading branch information
TheLLspectre committed Apr 3, 2024
1 parent 94abd0c commit ff66393
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
3 changes: 2 additions & 1 deletion package/Editor/Plugins/CommonUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ private static void SaveImage(byte[] pngBytes, string fileName, Preset importPre
importPreset = PluginSettings.TexturePreset;
}

string downloadPath = EditorPrefs.GetString("SaveFolder", "Assets");

string downloadPath = PluginSettings.SaveFolder;
string filePath = Path.Combine(downloadPath, fileName);

File.WriteAllBytesAsync(filePath, pngBytes).ContinueWith(task =>
Expand Down
30 changes: 26 additions & 4 deletions package/Editor/Settings/PluginSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,16 @@ public class PluginSettings : EditorWindow

public static string ApiUrl => "https://api.cloud.scenario.com/v1";
public static string WebAppUrl { get { return webAppUrl; } }
public static string SaveFolder { get { return EditorPrefs.GetString("SaveFolder"); } }
public static string SaveFolder {
get
{
if (!string.IsNullOrEmpty(EditorPrefs.GetString("SaveFolder")))
{
CheckAndCreateFolder(EditorPrefs.GetString("SaveFolder"));
}
return EditorPrefs.GetString("SaveFolder");
}
}
public static Preset TexturePreset { get { return GetPreset(EditorPrefs.GetString("scenario/texturePreset")); } }
public static Preset SpritePreset { get { return GetPreset(EditorPrefs.GetString("scenario/spritePreset")); } }
public static Preset TilePreset { get { return GetPreset(EditorPrefs.GetString("scenario/tilePreset")); } }
Expand Down Expand Up @@ -61,6 +70,12 @@ private class PackageInfo
public string version;
}

static PluginSettings()
{
GetVersionFromPackageJson();
PluginSettings settings = ScriptableObject.CreateInstance<PluginSettings>();
}

#region Unity Methods

private void OnEnable()
Expand Down Expand Up @@ -282,7 +297,7 @@ private void LoadSettings()
/// Check if the folder exist else create it.
/// </summary>
/// <param name="_folder"> Folder string </param>
private void CheckAndCreateFolder(string _folder)
private static void CheckAndCreateFolder(string _folder)
{
if (!AssetDatabase.IsValidFolder(_folder))
{
Expand All @@ -292,8 +307,15 @@ private void CheckAndCreateFolder(string _folder)
{
if (!path.Equals("Assets"))
{
AssetDatabase.CreateFolder(parentFolder, path);
parentFolder += "/" + path;
if (!AssetDatabase.IsValidFolder($"{parentFolder}/{path}"))
{
AssetDatabase.CreateFolder(parentFolder, path);
parentFolder += "/" + path;
}
else
{
parentFolder += "/" + path;
}
}
else
{
Expand Down

0 comments on commit ff66393

Please sign in to comment.