Skip to content

Commit

Permalink
Fix atlastool taking to long to load on v1
Browse files Browse the repository at this point in the history
  • Loading branch information
mdsitton committed Dec 1, 2022
1 parent 57e0959 commit 98a4d5f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
8 changes: 4 additions & 4 deletions AssetStudio/AssetStudio/AssetsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void LoadFiles(params string[] files)
public void LoadFolder(string path)
{
MergeSplitAssets(path, true);
var files = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories).ToList();
var files = Directory.GetFiles(path, "*.*", SearchOption.TopDirectoryOnly).ToList();
var toReadFile = ProcessingSplitFiles(files);
Load(toReadFile);
}
Expand Down Expand Up @@ -450,9 +450,9 @@ private void ReadAssets()
case ClassIDType.RectTransform:
obj = new RectTransform(objectReader);
break;
case ClassIDType.Shader:
obj = new Shader(objectReader);
break;
// case ClassIDType.Shader:
// obj = new Shader(objectReader);
// break;
case ClassIDType.SkinnedMeshRenderer:
obj = new SkinnedMeshRenderer(objectReader);
break;
Expand Down
1 change: 1 addition & 0 deletions atlascore/AssetStudioUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public static class AssetStudioUtil
{
public static AssetsManager LoadAssetManager(string path)
{
AssetStudio.Progress.Default = new Progress<int>((int val) => Console.Write($"\rLoading assets: {val,3}%"));
AssetsManager assetManager = new();

if (File.Exists(path))
Expand Down
11 changes: 9 additions & 2 deletions atlascore/AtlasOps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,21 +117,23 @@ public static void LoadTextures(AtlasData atlasData, string outputDir)

public static AtlasData? ReadAtlasDataFromAssets(string assetPath)
{
Console.Write("Loading assets");
AssetStudio.AssetsManager assetManager = AssetStudioUtil.LoadAssetManager(assetPath);
if (assetManager == null)
{
Console.WriteLine("Error: Could not load game data. Please ensure the input path is for the game's data folder or data.unity3d.");
return null;
}

Console.WriteLine("\nReading game version");
var gameVersion = AssetStudioUtil.GetGameVersion(assetManager.assetsFileList);


Console.WriteLine("Enumerating assets");
foreach (var atlas in assetManager.assetsFileList.EnumerateAssets<AssetStudio.SpriteAtlas>())
{
// Limit to just the fiveFretAtlas for now
if (atlas.m_Name != "fiveFretAtlas")
continue;
Console.WriteLine("Loading sprite data");

AtlasData atlasData = new(gameVersion, assetPath, atlas.m_Name, (int)atlas.m_PathID);
foreach (var sprite in atlas.EnumerateAtlasSprites())
Expand Down Expand Up @@ -222,12 +224,14 @@ public static void ExtractToFolder(string input, string output)
if (atlasData == null)
return;

Console.WriteLine($"Slicing sprites");
SliceSprites(atlasData);

var outputDir = Path.Combine(output, atlasData.GameVersion);
Directory.CreateDirectory(outputDir);
Directory.CreateDirectory(Path.Combine(outputDir, atlasData.Name));

Console.WriteLine($"Saving sprites to: {outputDir}");
SaveTextures(atlasData, outputDir);
byte[]?[] filesData = new byte[]?[atlasData.Sprites.Count];

Expand Down Expand Up @@ -274,7 +278,10 @@ public static void ExtractToFolder(string input, string output)
{
Console.WriteLine($"error saving texture: {sprite.Name}-{sprite.PathID}.png");
}

}

Console.WriteLine($"Done");
}

}

0 comments on commit 98a4d5f

Please sign in to comment.