This commit is contained in:
Perfare 2019-08-12 04:36:07 +08:00
parent 1d2c0ab6cb
commit b5d2c2cadb
4 changed files with 39 additions and 36 deletions

View File

@ -52,7 +52,7 @@ namespace AssetStudio
assetsFileListHash.Clear(); assetsFileListHash.Clear();
ReadAssets(); ReadAssets();
ProcessGameObject(); ProcessAssets();
} }
private void LoadFile(string fullName) private void LoadFile(string fullName)
@ -332,9 +332,9 @@ namespace AssetStudio
} }
} }
private void ProcessGameObject() private void ProcessAssets()
{ {
Logger.Info("Process GameObject..."); Logger.Info("Process Assets...");
foreach (var assetsFile in assetsFileList) foreach (var assetsFile in assetsFileList)
{ {
@ -370,6 +370,19 @@ namespace AssetStudio
} }
} }
} }
else if (obj is SpriteAtlas m_SpriteAtlas)
{
foreach (var m_PackedSprite in m_SpriteAtlas.m_PackedSprites)
{
if (m_PackedSprite.TryGet(out var m_Sprite))
{
if (m_Sprite.m_SpriteAtlas.IsNull)
{
m_Sprite.m_SpriteAtlas.Set(m_SpriteAtlas);
}
}
}
}
} }
} }
} }

View File

@ -126,6 +126,6 @@ namespace AssetStudio
m_PathID = m_Object.m_PathID; m_PathID = m_Object.m_PathID;
} }
public bool IsNull() => m_PathID == 0 || m_FileID < 0; public bool IsNull => m_PathID == 0 || m_FileID < 0;
} }
} }

View File

@ -1407,6 +1407,7 @@ namespace AssetStudioGUI
Logger.Default = new GUILogger(StatusStripUpdate); Logger.Default = new GUILogger(StatusStripUpdate);
Progress.Default = new GUIProgress(SetProgressBarValue); Progress.Default = new GUIProgress(SetProgressBarValue);
Studio.StatusStripUpdate = StatusStripUpdate;
} }
private void InitOpenTK() private void InitOpenTK()

View File

@ -25,6 +25,7 @@ namespace AssetStudioGUI
public static ScriptDumper scriptDumper = new ScriptDumper(); public static ScriptDumper scriptDumper = new ScriptDumper();
public static List<AssetItem> exportableAssets = new List<AssetItem>(); public static List<AssetItem> exportableAssets = new List<AssetItem>();
public static List<AssetItem> visibleAssets = new List<AssetItem>(); public static List<AssetItem> visibleAssets = new List<AssetItem>();
internal static Action<string> StatusStripUpdate = x => { };
public static void ExtractFile(string[] fileNames) public static void ExtractFile(string[] fileNames)
{ {
@ -45,13 +46,13 @@ namespace AssetStudioGUI
Progress.Report(i + 1, fileNames.Length); Progress.Report(i + 1, fileNames.Length);
} }
Logger.Info($"Finished extracting {extractedCount} files."); StatusStripUpdate($"Finished extracting {extractedCount} files.");
}); });
} }
private static int ExtractBundleFile(string bundleFileName, EndianBinaryReader reader) private static int ExtractBundleFile(string bundleFileName, EndianBinaryReader reader)
{ {
Logger.Info($"Decompressing {Path.GetFileName(bundleFileName)} ..."); StatusStripUpdate($"Decompressing {Path.GetFileName(bundleFileName)} ...");
var bundleFile = new BundleFile(reader, bundleFileName); var bundleFile = new BundleFile(reader, bundleFileName);
reader.Dispose(); reader.Dispose();
if (bundleFile.fileList.Count > 0) if (bundleFile.fileList.Count > 0)
@ -64,7 +65,7 @@ namespace AssetStudioGUI
private static int ExtractWebDataFile(string webFileName, EndianBinaryReader reader) private static int ExtractWebDataFile(string webFileName, EndianBinaryReader reader)
{ {
Logger.Info($"Decompressing {Path.GetFileName(webFileName)} ..."); StatusStripUpdate($"Decompressing {Path.GetFileName(webFileName)} ...");
var webFile = new WebFile(reader); var webFile = new WebFile(reader);
reader.Dispose(); reader.Dispose();
if (webFile.fileList.Count > 0) if (webFile.fileList.Count > 0)
@ -97,7 +98,7 @@ namespace AssetStudioGUI
public static void BuildAssetList(Dictionary<Object, AssetItem> tempDic, bool displayAll, bool displayOriginalName, out string productName) public static void BuildAssetList(Dictionary<Object, AssetItem> tempDic, bool displayAll, bool displayOriginalName, out string productName)
{ {
Logger.Info("Building asset list..."); StatusStripUpdate("Building asset list...");
productName = string.Empty; productName = string.Empty;
var assetsNameHash = new HashSet<string>(); var assetsNameHash = new HashSet<string>();
@ -175,18 +176,6 @@ namespace AssetStudioGUI
ab = m_AssetBundle; ab = m_AssetBundle;
assetItem.Text = ab.m_Name; assetItem.Text = ab.m_Name;
break; break;
case SpriteAtlas m_SpriteAtlas:
foreach (var m_PackedSprite in m_SpriteAtlas.m_PackedSprites)
{
if (m_PackedSprite.TryGet(out var m_Sprite))
{
if (m_Sprite.m_SpriteAtlas.IsNull())
{
m_Sprite.m_SpriteAtlas.Set(m_SpriteAtlas);
}
}
}
break;
case NamedObject m_NamedObject: case NamedObject m_NamedObject:
assetItem.Text = m_NamedObject.m_Name; assetItem.Text = m_NamedObject.m_Name;
break; break;
@ -245,7 +234,7 @@ namespace AssetStudioGUI
public static List<TreeNode> BuildTreeStructure(Dictionary<Object, AssetItem> tempDic) public static List<TreeNode> BuildTreeStructure(Dictionary<Object, AssetItem> tempDic)
{ {
Logger.Info("Building tree structure..."); StatusStripUpdate("Building tree structure...");
var treeNodeCollection = new List<TreeNode>(); var treeNodeCollection = new List<TreeNode>();
var treeNodeDictionary = new Dictionary<GameObject, GameObjectTreeNode>(); var treeNodeDictionary = new Dictionary<GameObject, GameObjectTreeNode>();
@ -383,7 +372,7 @@ namespace AssetStudioGUI
{ {
exportpath = savePath + "\\" + asset.TypeString + "\\"; exportpath = savePath + "\\" + asset.TypeString + "\\";
} }
Logger.Info($"Exporting {asset.TypeString}: {asset.Text}"); StatusStripUpdate($"Exporting {asset.TypeString}: {asset.Text}");
try try
{ {
switch (exportType) switch (exportType)
@ -496,7 +485,7 @@ namespace AssetStudioGUI
statusText += $" {toExportCount - exportedCount} assets skipped (not extractable or files already exist)"; statusText += $" {toExportCount - exportedCount} assets skipped (not extractable or files already exist)";
} }
Logger.Info(statusText); StatusStripUpdate(statusText);
if (openAfterExport && exportedCount > 0) if (openAfterExport && exportedCount > 0)
{ {
@ -544,7 +533,7 @@ namespace AssetStudioGUI
} }
Directory.CreateDirectory(targetPath); Directory.CreateDirectory(targetPath);
//导出FBX //导出FBX
Logger.Info($"Exporting {filename}.fbx"); StatusStripUpdate($"Exporting {filename}.fbx");
try try
{ {
ExportGameObject(j.gameObject, targetPath); ExportGameObject(j.gameObject, targetPath);
@ -555,14 +544,14 @@ namespace AssetStudioGUI
} }
Progress.Report(++k, count); Progress.Report(++k, count);
Logger.Info($"Finished exporting {filename}.fbx"); StatusStripUpdate($"Finished exporting {filename}.fbx");
} }
} }
if (openAfterExport) if (openAfterExport)
{ {
Process.Start(savePath); Process.Start(savePath);
} }
Logger.Info("Finished"); StatusStripUpdate("Finished");
}); });
} }
@ -580,7 +569,7 @@ namespace AssetStudioGUI
ThreadPool.QueueUserWorkItem(state => ThreadPool.QueueUserWorkItem(state =>
{ {
Progress.Reset(); Progress.Reset();
Logger.Info($"Exporting {animator.Text}"); StatusStripUpdate($"Exporting {animator.Text}");
try try
{ {
ExportAnimator(animator, exportPath, animationList); ExportAnimator(animator, exportPath, animationList);
@ -589,12 +578,12 @@ namespace AssetStudioGUI
Process.Start(exportPath); Process.Start(exportPath);
} }
Progress.Report(1, 1); Progress.Report(1, 1);
Logger.Info($"Finished exporting {animator.Text}"); StatusStripUpdate($"Finished exporting {animator.Text}");
} }
catch (Exception ex) catch (Exception ex)
{ {
MessageBox.Show($"Export Animator:{animator.Text} error\r\n{ex.Message}\r\n{ex.StackTrace}"); MessageBox.Show($"Export Animator:{animator.Text} error\r\n{ex.Message}\r\n{ex.StackTrace}");
Logger.Info("Error in export"); StatusStripUpdate("Error in export");
} }
}); });
} }
@ -612,16 +601,16 @@ namespace AssetStudioGUI
Progress.Reset(); Progress.Reset();
foreach (var gameObject in gameObjects) foreach (var gameObject in gameObjects)
{ {
Logger.Info($"Exporting {gameObject.m_Name}"); StatusStripUpdate($"Exporting {gameObject.m_Name}");
try try
{ {
ExportGameObject(gameObject, exportPath, animationList); ExportGameObject(gameObject, exportPath, animationList);
Logger.Info($"Finished exporting {gameObject.m_Name}"); StatusStripUpdate($"Finished exporting {gameObject.m_Name}");
} }
catch (Exception ex) catch (Exception ex)
{ {
MessageBox.Show($"Export GameObject:{gameObject.m_Name} error\r\n{ex.Message}\r\n{ex.StackTrace}"); MessageBox.Show($"Export GameObject:{gameObject.m_Name} error\r\n{ex.Message}\r\n{ex.StackTrace}");
Logger.Info("Error in export"); StatusStripUpdate("Error in export");
} }
Progress.Report(++i, count); Progress.Report(++i, count);
@ -633,7 +622,7 @@ namespace AssetStudioGUI
} }
else else
{ {
Logger.Info("No Object can be exported."); StatusStripUpdate("No Object can be exported.");
} }
}); });
} }
@ -644,17 +633,17 @@ namespace AssetStudioGUI
{ {
var name = Path.GetFileName(exportPath); var name = Path.GetFileName(exportPath);
Progress.Reset(); Progress.Reset();
Logger.Info($"Exporting {name}"); StatusStripUpdate($"Exporting {name}");
try try
{ {
ExportGameObjectMerge(gameObjects, exportPath, animationList); ExportGameObjectMerge(gameObjects, exportPath, animationList);
Progress.Report(1, 1); Progress.Report(1, 1);
Logger.Info($"Finished exporting {name}"); StatusStripUpdate($"Finished exporting {name}");
} }
catch (Exception ex) catch (Exception ex)
{ {
MessageBox.Show($"Export Model:{name} error\r\n{ex.Message}\r\n{ex.StackTrace}"); MessageBox.Show($"Export Model:{name} error\r\n{ex.Message}\r\n{ex.StackTrace}");
Logger.Info("Error in export"); StatusStripUpdate("Error in export");
} }
if (openAfterExport) if (openAfterExport)
{ {