support use asset original name when display and export

This commit is contained in:
Perfare 2017-04-01 04:28:46 +08:00
parent bd18bfb8ea
commit f8e7303169
8 changed files with 103 additions and 5 deletions

View File

@ -226,5 +226,17 @@ namespace Unity_Studio.Properties {
this["convertType"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool displayOriginalName {
get {
return ((bool)(this["displayOriginalName"]));
}
set {
this["displayOriginalName"] = value;
}
}
}
}

View File

@ -53,5 +53,8 @@
<Setting Name="convertType" Type="System.String" Scope="User">
<Value Profile="(Default)">PNG</Value>
</Setting>
<Setting Name="displayOriginalName" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>

View File

@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Unity_Studio
{
class AssetBundle
{
public class AssetInfo
{
public int preloadIndex;
public int preloadSize;
public PPtr asset;
}
public class ContainerData
{
public string first;
public AssetInfo second;
}
public List<ContainerData> m_Container = new List<ContainerData>();
public AssetBundle(AssetPreloadData preloadData)
{
var sourceFile = preloadData.sourceFile;
var a_Stream = preloadData.sourceFile.a_Stream;
a_Stream.Position = preloadData.Offset;
var m_Name = a_Stream.ReadAlignedString(a_Stream.ReadInt32());
var size = a_Stream.ReadInt32();
for (int i = 0; i < size; i++)
{
sourceFile.ReadPPtr();
}
size = a_Stream.ReadInt32();
for (int i = 0; i < size; i++)
{
var temp = new ContainerData();
temp.first = a_Stream.ReadAlignedString(a_Stream.ReadInt32());
temp.second = new AssetInfo();
temp.second.preloadIndex = a_Stream.ReadInt32();
temp.second.preloadSize = a_Stream.ReadInt32();
temp.second.asset = sourceFile.ReadPPtr();
m_Container.Add(temp);
}
}
}
}

View File

@ -240,7 +240,7 @@ namespace Unity_Studio
return extractedCount;
}
public static void BuildAssetStructures(bool loadAssetsMenuItem, bool displayAll, bool buildHierarchyMenuItem, bool buildClassStructuresMenuItem)
public static void BuildAssetStructures(bool loadAssetsMenuItem, bool displayAll, bool buildHierarchyMenuItem, bool buildClassStructuresMenuItem, bool displayOriginalName)
{
#region first loop - read asset data & create list
if (loadAssetsMenuItem)
@ -255,7 +255,7 @@ namespace Unity_Studio
StatusStripUpdate("Building asset list from " + Path.GetFileName(assetsFile.filePath));
string fileID = i.ToString(fileIDfmt);
AssetBundle ab = null;
foreach (var asset in assetsFile.preloadTable.Values)
{
asset.uniqueID = fileID + asset.uniqueID;
@ -330,6 +330,11 @@ namespace Unity_Studio
exportable = true;
break;
}
case 142: //AssetBundle
{
ab = new AssetBundle(asset);
break;
}
case 21: //Material
case 74: //AnimationClip
case 90: //Avatar
@ -370,6 +375,15 @@ namespace Unity_Studio
}
ProgressBarPerformStep();
}
if (displayOriginalName)
{
assetsFile.exportableAssets.ForEach(x =>
{
var replacename = ab?.m_Container.Find(y => y.second.asset.m_PathID == x.m_PathID)?.first;
if (!string.IsNullOrEmpty(replacename))
x.Text = replacename.Replace(Path.GetExtension(replacename), "");
});
}
exportableAssets.AddRange(assetsFile.exportableAssets);
//if (assetGroup.Items.Count > 0) { listView1.Groups.Add(assetGroup); }
}

View File

@ -159,6 +159,7 @@
<Compile Include="AboutBox.Designer.cs">
<DependentUpon>AboutBox.cs</DependentUpon>
</Compile>
<Compile Include="Unity Classes\AssetBundle.cs" />
<Compile Include="Unity Studio Classes\AssetPreloadData.cs" />
<Compile Include="Unity Classes\AudioClip.cs" />
<Compile Include="Unity Classes\BuildSettings.cs" />

View File

@ -45,6 +45,7 @@
this.exportClassStructuresMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.displayAll = new System.Windows.Forms.ToolStripMenuItem();
this.displayOriginalName = 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();
@ -233,6 +234,7 @@
//
this.optionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.displayAll,
this.displayOriginalName,
this.enablePreview,
this.displayInfo,
this.openAfterExport,
@ -242,6 +244,15 @@
this.optionsToolStripMenuItem.Size = new System.Drawing.Size(61, 20);
this.optionsToolStripMenuItem.Text = "Options";
//
// displayOriginalName
//
this.displayOriginalName.CheckOnClick = true;
this.displayOriginalName.Name = "displayOriginalName";
this.displayOriginalName.Size = new System.Drawing.Size(252, 22);
this.displayOriginalName.Text = "Display asset original name";
this.displayOriginalName.ToolTipText = "Check this option will use asset original name when display and export";
this.displayOriginalName.CheckedChanged += new System.EventHandler(this.MenuItem_CheckedChanged);
//
// displayAll
//
this.displayAll.CheckOnClick = true;
@ -808,7 +819,7 @@
//
// timerOpenTK
//
this.timerOpenTK.Interval = 1000/6;
this.timerOpenTK.Interval = 1000 / 6;
this.timerOpenTK.Tick += new System.EventHandler(this.timerOpenTK_Tick);
//
// openFileDialog1
@ -929,6 +940,7 @@
private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem optionsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem displayAll;
private System.Windows.Forms.ToolStripMenuItem displayOriginalName;
private System.Windows.Forms.ToolStripMenuItem enablePreview;
private System.Windows.Forms.ToolStripMenuItem displayInfo;
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem1;

View File

@ -269,7 +269,7 @@ namespace Unity_Studio
bool optionBuildHierarchyMenuItem = !dontBuildHierarchyMenuItem.Checked;
bool optionBuildClassStructuresMenuItem = buildClassStructuresMenuItem.Checked;
BuildAssetStructures(optionLoadAssetsMenuItem, optionDisplayAll, optionBuildHierarchyMenuItem, optionBuildClassStructuresMenuItem);
BuildAssetStructures(optionLoadAssetsMenuItem, optionDisplayAll, optionBuildHierarchyMenuItem, optionBuildClassStructuresMenuItem, displayOriginalName.Checked);
BeginInvoke(new Action(() =>
{
@ -1069,7 +1069,7 @@ namespace Unity_Studio
textPreviewBox.Visible = true;
}
else*/
StatusStripUpdate("Only supported export the raw file.");
StatusStripUpdate("Only supported export the raw file.");
break;
}
}
@ -1682,6 +1682,7 @@ namespace Unity_Studio
{
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
InitializeComponent();
displayOriginalName.Checked = (bool)Properties.Settings.Default["displayOriginalName"];
displayAll.Checked = (bool)Properties.Settings.Default["displayAll"];
displayInfo.Checked = (bool)Properties.Settings.Default["displayInfo"];
enablePreview.Checked = (bool)Properties.Settings.Default["enablePreview"];

View File

@ -58,6 +58,9 @@
<setting name="convertType" serializeAs="String">
<value>PNG</value>
</setting>
<setting name="displayOriginalName" serializeAs="String">
<value>False</value>
</setting>
</Unity_Studio.Properties.Settings>
</userSettings>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup>