Skip to content

Commit

Permalink
fix: delete downloaded folder in lods process (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
dalkia authored Mar 20, 2024
1 parent adac35c commit 58f72ea
Showing 1 changed file with 8 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public LODConversion(string customOutputPath, string[] urlsToConvert)
public async void ConvertLODs()
{
PlatformUtils.currentTarget = EditorUserBuildSettings.activeBuildTarget;
//TODO (Juani) Temporal hack. Clean with the regular asset bundle process
ClearDownloadedFolder();
IAssetDatabase assetDatabase = new UnityEditorWrappers.AssetDatabase();
string[] downloadedFilePaths;
try
Expand Down Expand Up @@ -61,33 +63,6 @@ public async void ConvertLODs()
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
assetDatabase.AssignAssetBundle(Shader.Find("DCL/Scene"), false);

string[] assetBundleNames = AssetDatabase.GetAllAssetBundleNames();
// Dictionary to hold asset bundle names and their assets
var bundleAssets = new Dictionary<string, List<string>>();

foreach (string name in assetBundleNames)
{
// Initialize the list for this bundle
bundleAssets[name] = new List<string>();

// Get the asset paths for each asset in the bundle
string[] assetPaths = AssetDatabase.GetAssetPathsFromAssetBundle(name);

foreach (string path in assetPaths)
{
Debug.Log($"JUANI ASSET {name} has path {path}");
bundleAssets[name].Add(path);
}
}

// Get all file names in all directories and subdirectories.
string[] files = Directory.GetFiles(lodPathHandler.tempPath, "*.*", SearchOption.AllDirectories);

// Print the name of each file.
foreach (string file in files)
Debug.Log($"JUANI File {file} is is temp path");

BuildAssetBundles(EditorUserBuildSettings.activeBuildTarget, dictionaryStringForMetadata);
}
catch (Exception e)
Expand All @@ -105,6 +80,12 @@ public async void ConvertLODs()
Utils.Exit();
}

private void ClearDownloadedFolder()
{
if (Directory.Exists(Config.GetDownloadPath()))
Directory.Delete(Config.GetDownloadPath(), true);
}

private async Task<string[]> DownloadFiles()
{
var urlFileDownloader = new URLFileDownloader(urlsToConvert, lodPathHandler.tempPath);
Expand Down

0 comments on commit 58f72ea

Please sign in to comment.