- remove "Unique exported filenames" option (assets of the same name will always add a unique numeric identifier)

- add "Display all assets" option to support display all types assets and export the RAW file.(use .dat extension)
This commit is contained in:
Perfare 2016-08-13 08:20:38 +08:00
parent 03b2ab97d6
commit ff144b41eb
9 changed files with 117 additions and 66 deletions

View File

@ -182,6 +182,10 @@ namespace Unity_Studio
{
asset.TypeString = UnityClassID.Names[asset.Type2];
}
else
{
asset.TypeString = "unknown";
}
asset.uniqueID = i.ToString(assetIDfmt);

View File

@ -123,7 +123,15 @@ namespace Unity_Studio
var bundleSize = b_Stream.ReadInt64();
int compressedSize = b_Stream.ReadInt32();
int uncompressedSize = b_Stream.ReadInt32();
int unknown = b_Stream.ReadInt32();//Hmm...
// (UnityFS) flags
// 0x100 = <unknown>
// 0x80 = data header at end of file
// 0x40 = entry info present
// 0x3f = low six bits are data header compression method
// 0 = none
// 1 = LZMA
// 3 = LZ4
int unknown = b_Stream.ReadInt32();
var entryinfoBytes = b_Stream.ReadBytes(compressedSize);
EndianStream entryinfo;
if (uncompressedSize > compressedSize)
@ -151,6 +159,11 @@ namespace Unity_Studio
{
uncompressedSize = entryinfo.ReadInt32();
compressedSize = entryinfo.ReadInt32();
//0 = none
//1 = LZMA
//3 = LZ4
//0x40 = 0?
unknown = entryinfo.ReadInt16();
var compressedBytes = b_Stream.ReadBytes(compressedSize);
if (uncompressedSize > compressedSize)
{
@ -167,7 +180,6 @@ namespace Unity_Studio
{
assetsDatam.Write(compressedBytes, 0, compressedSize);
}
unknown = entryinfo.ReadInt16();
}
//assetsDatam.Capacity = (int)assetsDatam.Length;
assetsData = new EndianStream(assetsDatam, EndianType.BigEndian);

View File

@ -25,13 +25,13 @@ namespace Unity_Studio.Properties {
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("True")]
public bool uniqueNames {
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool displayAll {
get {
return ((bool)(this["uniqueNames"]));
return ((bool)(this["displayAll"]));
}
set {
this["uniqueNames"] = value;
this["displayAll"] = value;
}
}

View File

@ -2,8 +2,8 @@
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="Unity_Studio.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="uniqueNames" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
<Setting Name="displayAll" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="enablePreview" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>

View File

@ -69,6 +69,7 @@ namespace Unity_Studio
m_IsActive = a_Stream.ReadBoolean();
base.Text = m_Name;
preloadData.Text = m_Name;
//name should be unique
base.Name = uniqueID;
}

View File

@ -44,7 +44,7 @@
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.exportClassStructuresMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.uniqueNames = new System.Windows.Forms.ToolStripMenuItem();
this.displayAll = new System.Windows.Forms.ToolStripMenuItem();
this.enablePreview = new System.Windows.Forms.ToolStripMenuItem();
this.displayInfo = new System.Windows.Forms.ToolStripMenuItem();
this.openAfterExport = new System.Windows.Forms.ToolStripMenuItem();
@ -228,7 +228,7 @@
// optionsToolStripMenuItem
//
this.optionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.uniqueNames,
this.displayAll,
this.enablePreview,
this.displayInfo,
this.openAfterExport,
@ -238,16 +238,15 @@
this.optionsToolStripMenuItem.Size = new System.Drawing.Size(66, 21);
this.optionsToolStripMenuItem.Text = "Options";
//
// uniqueNames
// displayAll
//
this.uniqueNames.Checked = true;
this.uniqueNames.CheckOnClick = true;
this.uniqueNames.CheckState = System.Windows.Forms.CheckState.Checked;
this.uniqueNames.Name = "uniqueNames";
this.uniqueNames.Size = new System.Drawing.Size(252, 22);
this.uniqueNames.Text = "Unique exported filenames";
this.uniqueNames.ToolTipText = resources.GetString("uniqueNames.ToolTipText");
this.uniqueNames.CheckedChanged += new System.EventHandler(this.MenuItem_CheckedChanged);
this.displayAll.CheckOnClick = true;
this.displayAll.Name = "displayAll";
this.displayAll.Size = new System.Drawing.Size(252, 22);
this.displayAll.Text = "Display all assets";
this.displayAll.ToolTipText = "Check this option will display all types assets. Not extractable assets can expor" +
"t the RAW file.";
this.displayAll.CheckedChanged += new System.EventHandler(this.MenuItem_CheckedChanged);
//
// enablePreview
//
@ -899,7 +898,7 @@
private System.Windows.Forms.Timer timer;
private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem optionsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem uniqueNames;
private System.Windows.Forms.ToolStripMenuItem displayAll;
private System.Windows.Forms.ToolStripMenuItem enablePreview;
private System.Windows.Forms.ToolStripMenuItem displayInfo;
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem1;

View File

@ -360,7 +360,7 @@ namespace Unity_Studio
{
b_assetsfileList.Add(assetsFile);
}
assetsfileandstream.Add(assetsFile.fileName, assetsFile.a_Stream);
assetsfileandstream[assetsFile.fileName] = assetsFile.a_Stream;
}
if (b_assetsfileList.Count > 0)
{
@ -668,7 +668,7 @@ namespace Unity_Studio
foreach (var asset in assetsFile.preloadTable.Values)
{
asset.uniqueID = fileID + asset.uniqueID;
var exportable = false;
switch (asset.Type2)
{
case 1: //GameObject
@ -694,43 +694,27 @@ namespace Unity_Studio
case 28: //Texture2D
{
Texture2D m_Texture2D = new Texture2D(asset, false);
if (!exportableAssetsHash.Add("Texture2D" + asset.Text))
{
asset.Text += " #" + asset.uniqueID;
}
assetsFile.exportableAssets.Add(asset);
exportable = true;
break;
}
case 48: //Shader
case 49: //TextAsset
{
TextAsset m_TextAsset = new TextAsset(asset, false);
if (!exportableAssetsHash.Add("TextAsset" + asset.Text))
{
asset.Text += " #" + asset.uniqueID;
}
assetsFile.exportableAssets.Add(asset);
exportable = true;
break;
}
case 83: //AudioClip
{
AudioClip m_AudioClip = new AudioClip(asset, false);
if (!exportableAssetsHash.Add("AudioClip" + asset.Text))
{
asset.Text += " #" + asset.uniqueID;
}
assetsFile.exportableAssets.Add(asset);
exportable = true;
break;
}
//case 89: //CubeMap
case 128: //Font
{
unityFont m_Font = new unityFont(asset, false);
if (!exportableAssetsHash.Add("unityFont" + asset.Text))
{
asset.Text += " #" + asset.uniqueID;
}
assetsFile.exportableAssets.Add(asset);
exportable = true;
break;
}
case 129: //PlayerSettings
@ -739,9 +723,52 @@ namespace Unity_Studio
productName = plSet.productName;
break;
}
case 0:
break;
case 114: //MonoBehaviour
{
asset.sourceFile.a_Stream.Position = asset.Offset + 0x1c;
var len = asset.sourceFile.a_Stream.ReadInt32();
if (len > 0 && len < asset.Size)
{
var bytes = asset.sourceFile.a_Stream.ReadBytes(len);
asset.Text = Encoding.UTF8.GetString(bytes);
}
break;
}
case 21: //Material
case 43: //Mesh
case 74: //AnimationClip
case 90: //Avatar
case 91: //AnimatorController
case 115: //MonoScript
case 213: //Sprite
{
asset.sourceFile.a_Stream.Position = asset.Offset;
var len = asset.sourceFile.a_Stream.ReadInt32();
if (len > 0 && len < asset.Size)
{
var bytes = asset.sourceFile.a_Stream.ReadBytes(len);
asset.Text = Encoding.UTF8.GetString(bytes);
}
break;
}
}
if (!exportable && displayAll.Checked)
{
if(asset.Text == "")
{
asset.Text = asset.TypeString + " #" + asset.uniqueID;
}
asset.extension = ".dat";
asset.SubItems.AddRange(new string[] { asset.TypeString, asset.Size.ToString() });
exportable = true;
}
if (exportable)
{
if (!exportableAssetsHash.Add(asset.TypeString + asset.Text))
{
asset.Text += " #" + asset.uniqueID;
}
assetsFile.exportableAssets.Add(asset);
}
}
@ -1315,7 +1342,12 @@ namespace Unity_Studio
break;
}
#endregion
#endregion
default:
{
StatusStripUpdate("Only supported export the raw file.");
break;
}
}
}
@ -3045,6 +3077,14 @@ namespace Unity_Studio
exportedCount++;
}
break;
default:
if (!ExportFileExists(exportpath + asset.Text + asset.extension, asset.TypeString))
{
ExportRawFile(asset, exportpath + asset.Text + asset.extension);
exportedCount++;
}
break;
}
ProgressBarPerformStep();
}
@ -3072,6 +3112,13 @@ namespace Unity_Studio
}
}
private void ExportRawFile(AssetPreloadData asset, string exportFilepath)
{
asset.sourceFile.a_Stream.Position = asset.Offset;
var bytes = asset.sourceFile.a_Stream.ReadBytes(asset.Size);
File.WriteAllBytes(exportFilepath, bytes);
}
private bool ExportTexture(AssetPreloadData asset, string exportFilename, string exportFileextension)
{
ImageFormat format = null;
@ -3160,9 +3207,7 @@ namespace Unity_Studio
}
else
{
BinaryWriter writer = new BinaryWriter(File.Open(exportFullname, FileMode.Create));
writer.Write(m_Texture2D.image_data);
writer.Close();
File.WriteAllBytes(exportFullname, m_Texture2D.image_data);
}
return true;
}
@ -3234,27 +3279,21 @@ namespace Unity_Studio
}
else
{
BinaryWriter writer = new BinaryWriter(File.Open(exportFilename, FileMode.Create));
writer.Write(m_AudioClip.m_AudioData);
writer.Close();
File.WriteAllBytes(exportFilename, m_AudioClip.m_AudioData);
}
return true;
}
private void ExportText(TextAsset m_TextAsset, string exportFilename)
{
BinaryWriter writer = new BinaryWriter(File.Open(exportFilename, FileMode.Create));
writer.Write(m_TextAsset.m_Script);
writer.Close();
File.WriteAllBytes(exportFilename, m_TextAsset.m_Script);
}
private void ExportFont(unityFont m_Font, string exportFilename)
{
if (m_Font.m_FontData != null)
{
BinaryWriter writer = new BinaryWriter(File.Open(exportFilename, FileMode.Create));
writer.Write(m_Font.m_FontData);
writer.Close();
File.WriteAllBytes(exportFilename, m_Font.m_FontData);
}
}
@ -3326,7 +3365,7 @@ namespace Unity_Studio
{
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
InitializeComponent();
uniqueNames.Checked = (bool)Properties.Settings.Default["uniqueNames"];
displayAll.Checked = (bool)Properties.Settings.Default["displayAll"];
displayInfo.Checked = (bool)Properties.Settings.Default["displayInfo"];
enablePreview.Checked = (bool)Properties.Settings.Default["enablePreview"];
openAfterExport.Checked = (bool)Properties.Settings.Default["openAfterExport"];

View File

@ -120,10 +120,6 @@
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>325, 17</value>
</metadata>
<data name="uniqueNames.ToolTipText" xml:space="preserve">
<value>Two or more assets may have the same name, and Unity Studio will never overwrite an existing file.
Check this option to add a unique numeric identifier at the end of each filename, and ensure that all assets are extracted.</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="previewPanel.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
@ -172,7 +168,7 @@ Check this option to add a unique numeric identifier at the end of each filename
XTesb3QPLh88M+QwdP6m681Lt7xuXbu94vbgcOjwnZHokdE77DtTd1PuvriXeW/h/sYH6AdFD6UeVjxS
fNTws+7PbaOWo6fHXMf6Hwc/vj/OGn/2S8Yv7ycKnpCfVEyqTDZPmU2dmnafvvF05dOJZ+nPFmYKf5X+
tfa5zvMffnP8rX82YnbiBf/Fp99LXsq/PPRq2aueuYC5R69TXy/MF72Rf3P4LeNt37vwd5MLWe+x7ys/
6H7o/ujz8cGn1E+f/gUDmPP8usTo0wAAAAlwSFlzAAALDwAACw8BkvkDpQAAHOJJREFUeF7t3Q2V5TYS
6H7o/ujz8cGn1E+f/gUDmPP8usTo0wAAAAlwSFlzAAALDAAACwwBP0AiyAAAHOJJREFUeF7t3Q2V5TYS
huGFEAiBsBACIRACIRACIRACIRACYSEEwjLI+pvTmtWoX0lVtuy+Pfp8znN2R23plmVV+ef2ZP71zz//
mNmmsNHM9oCNZrYHbDSzPWCjme0BG81sD9hoZnvARjPbAzaa2R6w0cz2gI1mtgdsNLM9YKOZ7QEbzWwP
2Ghme8BGM9sDNprZHrDRzPaAjWa2B2w0sz1go5ntARvNbA/YaGZ7wEYz2wM2mtkesNHM9oCNZrYHbDSz

View File

@ -7,8 +7,8 @@
</configSections>
<userSettings>
<Unity_Studio.Properties.Settings>
<setting name="uniqueNames" serializeAs="String">
<value>True</value>
<setting name="displayAll" serializeAs="String">
<value>False</value>
</setting>
<setting name="enablePreview" serializeAs="String">
<value>True</value>