diff --git a/Unity Studio/AssetsFile.cs b/Unity Studio/AssetsFile.cs index 02fb54c..199f819 100644 --- a/Unity Studio/AssetsFile.cs +++ b/Unity Studio/AssetsFile.cs @@ -182,6 +182,10 @@ namespace Unity_Studio { asset.TypeString = UnityClassID.Names[asset.Type2]; } + else + { + asset.TypeString = "unknown"; + } asset.uniqueID = i.ToString(assetIDfmt); diff --git a/Unity Studio/BundleFile.cs b/Unity Studio/BundleFile.cs index 992e8c2..d8f7d73 100644 --- a/Unity Studio/BundleFile.cs +++ b/Unity Studio/BundleFile.cs @@ -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 = + // 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); diff --git a/Unity Studio/Properties/Settings.Designer.cs b/Unity Studio/Properties/Settings.Designer.cs index 8006a20..30223fa 100644 --- a/Unity Studio/Properties/Settings.Designer.cs +++ b/Unity Studio/Properties/Settings.Designer.cs @@ -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; } } diff --git a/Unity Studio/Properties/Settings.settings b/Unity Studio/Properties/Settings.settings index 08bdf91..e3ce73f 100644 --- a/Unity Studio/Properties/Settings.settings +++ b/Unity Studio/Properties/Settings.settings @@ -2,8 +2,8 @@ - - True + + False True diff --git a/Unity Studio/Unity Classes/GameObject.cs b/Unity Studio/Unity Classes/GameObject.cs index de4259d..068ff7d 100644 --- a/Unity Studio/Unity Classes/GameObject.cs +++ b/Unity Studio/Unity Classes/GameObject.cs @@ -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; } diff --git a/Unity Studio/UnityStudioForm.Designer.cs b/Unity Studio/UnityStudioForm.Designer.cs index 0110ca3..ba09062 100644 --- a/Unity Studio/UnityStudioForm.Designer.cs +++ b/Unity Studio/UnityStudioForm.Designer.cs @@ -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; diff --git a/Unity Studio/UnityStudioForm.cs b/Unity Studio/UnityStudioForm.cs index 5ee248c..bd021d9 100644 --- a/Unity Studio/UnityStudioForm.cs +++ b/Unity Studio/UnityStudioForm.cs @@ -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"]; diff --git a/Unity Studio/UnityStudioForm.resx b/Unity Studio/UnityStudioForm.resx index d786e34..01d54ed 100644 --- a/Unity Studio/UnityStudioForm.resx +++ b/Unity Studio/UnityStudioForm.resx @@ -120,10 +120,6 @@ 325, 17 - - 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. - @@ -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 diff --git a/Unity Studio/app.config b/Unity Studio/app.config index 089b67a..8c4d3ac 100644 --- a/Unity Studio/app.config +++ b/Unity Studio/app.config @@ -7,8 +7,8 @@ - - True + + False True