mirror of
https://github.com/aelurum/AssetStudio.git
synced 2025-07-18 03:24:15 -04:00
Refactor MonoBehaviour reading
This commit is contained in:
@ -930,7 +930,7 @@ namespace AssetStudioGUI
|
||||
|
||||
private void PreviewMonoBehaviour(MonoBehaviour m_MonoBehaviour)
|
||||
{
|
||||
PreviewText(m_MonoBehaviour.Dump() ?? GetScriptString(m_MonoBehaviour.reader));
|
||||
PreviewText(m_MonoBehaviour.Dump() ?? DeserializeMonoBehaviour(m_MonoBehaviour));
|
||||
}
|
||||
|
||||
private void PreviewFont(Font m_Font)
|
||||
@ -1192,6 +1192,7 @@ namespace AssetStudioGUI
|
||||
{
|
||||
Text = $"AssetStudioGUI v{Application.ProductVersion}";
|
||||
assetsManager.Clear();
|
||||
assemblyLoader.Clear();
|
||||
exportableAssets.Clear();
|
||||
visibleAssets.Clear();
|
||||
sceneTreeView.Nodes.Clear();
|
||||
@ -1221,12 +1222,6 @@ namespace AssetStudioGUI
|
||||
}
|
||||
|
||||
FMODreset();
|
||||
|
||||
if (scriptDumper != null)
|
||||
{
|
||||
scriptDumper.Dispose();
|
||||
scriptDumper = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void assetListView_MouseClick(object sender, MouseEventArgs e)
|
||||
|
@ -116,7 +116,7 @@ namespace AssetStudioGUI
|
||||
if (!TryExportFile(exportPath, item, ".txt", out var exportFullPath))
|
||||
return false;
|
||||
var m_MonoBehaviour = (MonoBehaviour)item.Asset;
|
||||
var str = m_MonoBehaviour.Dump() ?? Studio.GetScriptString(item.Asset.reader);
|
||||
var str = m_MonoBehaviour.Dump() ?? Studio.DeserializeMonoBehaviour(m_MonoBehaviour);
|
||||
File.WriteAllText(exportFullPath, str);
|
||||
return true;
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using static AssetStudioGUI.Exporter;
|
||||
@ -22,7 +23,7 @@ namespace AssetStudioGUI
|
||||
internal static class Studio
|
||||
{
|
||||
public static AssetsManager assetsManager = new AssetsManager();
|
||||
public static ScriptDumper scriptDumper = new ScriptDumper();
|
||||
public static AssemblyLoader assemblyLoader = new AssemblyLoader();
|
||||
public static List<AssetItem> exportableAssets = new List<AssetItem>();
|
||||
public static List<AssetItem> visibleAssets = new List<AssetItem>();
|
||||
internal static Action<string> StatusStripUpdate = x => { };
|
||||
@ -614,23 +615,29 @@ namespace AssetStudioGUI
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetScriptString(ObjectReader reader)
|
||||
public static string DeserializeMonoBehaviour(MonoBehaviour m_MonoBehaviour)
|
||||
{
|
||||
if (scriptDumper == null)
|
||||
if (!assemblyLoader.Loaded)
|
||||
{
|
||||
var openFolderDialog = new OpenFolderDialog();
|
||||
openFolderDialog.Title = "Select Assembly Folder";
|
||||
if (openFolderDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
scriptDumper = new ScriptDumper(openFolderDialog.Folder);
|
||||
assemblyLoader.Load(openFolderDialog.Folder);
|
||||
}
|
||||
else
|
||||
{
|
||||
scriptDumper = new ScriptDumper();
|
||||
assemblyLoader.Loaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
return scriptDumper.DumpScript(reader);
|
||||
var nodes = m_MonoBehaviour.ConvertToTypeTreeNode(assemblyLoader);
|
||||
if (nodes != null)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
TypeTreeHelper.ReadTypeString(sb, nodes, m_MonoBehaviour.reader);
|
||||
return sb.ToString();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user