From 4d85c7f6655db8d8b23db1beabc4c6b3214532f8 Mon Sep 17 00:00:00 2001 From: Perfare Date: Mon, 22 Jan 2018 03:55:30 +0800 Subject: [PATCH] improve AudioClip export --- Unity Studio/ExportOptions.Designer.cs | 168 ++++++--------- Unity Studio/ExportOptions.cs | 4 +- Unity Studio/ExportOptions.resx | 3 - Unity Studio/Properties/Settings.Designer.cs | 8 +- Unity Studio/Properties/Settings.settings | 2 +- Unity Studio/Unity Classes/AudioClip.cs | 204 +++++++++++++----- Unity Studio/Unity Classes/Texture2D.cs | 61 ------ .../Unity Studio Classes/UnityEnum.cs | 99 +++++++++ .../Unity Studio Classes/UnityStudio.cs | 59 +++-- Unity Studio/Unity Studio-x86.csproj | 1 + Unity Studio/Unity Studio.csproj | 5 +- Unity Studio/app.config | 2 +- 12 files changed, 356 insertions(+), 260 deletions(-) create mode 100644 Unity Studio/Unity Studio Classes/UnityEnum.cs diff --git a/Unity Studio/ExportOptions.Designer.cs b/Unity Studio/ExportOptions.Designer.cs index c9b4db7..7a63283 100644 --- a/Unity Studio/ExportOptions.Designer.cs +++ b/Unity Studio/ExportOptions.Designer.cs @@ -46,10 +46,9 @@ this.scaleLabel = new System.Windows.Forms.Label(); this.fbxOKbutton = new System.Windows.Forms.Button(); this.fbxCancel = new System.Windows.Forms.Button(); - this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog(); this.showExpOpt = new System.Windows.Forms.CheckBox(); this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.convertfsb = new System.Windows.Forms.CheckBox(); + this.convertAudio = new System.Windows.Forms.CheckBox(); this.panel1 = new System.Windows.Forms.Panel(); this.tojpg = new System.Windows.Forms.RadioButton(); this.topng = new System.Windows.Forms.RadioButton(); @@ -72,11 +71,9 @@ this.includeBox.Controls.Add(this.camerasBox); this.includeBox.Controls.Add(this.exportDeformers); this.includeBox.Controls.Add(this.geometryBox); - this.includeBox.Location = new System.Drawing.Point(16, 15); - this.includeBox.Margin = new System.Windows.Forms.Padding(4); + this.includeBox.Location = new System.Drawing.Point(12, 12); this.includeBox.Name = "includeBox"; - this.includeBox.Padding = new System.Windows.Forms.Padding(4); - this.includeBox.Size = new System.Drawing.Size(332, 334); + this.includeBox.Size = new System.Drawing.Size(249, 267); this.includeBox.TabIndex = 0; this.includeBox.TabStop = false; this.includeBox.Text = "Include"; @@ -84,10 +81,9 @@ // convertDummies // this.convertDummies.AutoSize = true; - this.convertDummies.Location = new System.Drawing.Point(19, 205); - this.convertDummies.Margin = new System.Windows.Forms.Padding(4); + this.convertDummies.Location = new System.Drawing.Point(14, 164); this.convertDummies.Name = "convertDummies"; - this.convertDummies.Size = new System.Drawing.Size(302, 20); + this.convertDummies.Size = new System.Drawing.Size(228, 16); this.convertDummies.TabIndex = 5; this.convertDummies.Text = "Convert Deforming Dummies to Bones"; this.convertDummies.UseVisualStyleBackColor = true; @@ -97,10 +93,9 @@ // this.embedBox.AutoSize = true; this.embedBox.Enabled = false; - this.embedBox.Location = new System.Drawing.Point(19, 288); - this.embedBox.Margin = new System.Windows.Forms.Padding(4); + this.embedBox.Location = new System.Drawing.Point(14, 230); this.embedBox.Name = "embedBox"; - this.embedBox.Size = new System.Drawing.Size(118, 20); + this.embedBox.Size = new System.Drawing.Size(90, 16); this.embedBox.TabIndex = 4; this.embedBox.Text = "Embed Media"; this.embedBox.UseVisualStyleBackColor = true; @@ -109,10 +104,9 @@ // this.lightsBox.AutoSize = true; this.lightsBox.Enabled = false; - this.lightsBox.Location = new System.Drawing.Point(19, 260); - this.lightsBox.Margin = new System.Windows.Forms.Padding(4); + this.lightsBox.Location = new System.Drawing.Point(14, 208); this.lightsBox.Name = "lightsBox"; - this.lightsBox.Size = new System.Drawing.Size(78, 20); + this.lightsBox.Size = new System.Drawing.Size(60, 16); this.lightsBox.TabIndex = 3; this.lightsBox.Text = "Lights"; this.lightsBox.UseVisualStyleBackColor = true; @@ -121,10 +115,9 @@ // this.camerasBox.AutoSize = true; this.camerasBox.Enabled = false; - this.camerasBox.Location = new System.Drawing.Point(19, 232); - this.camerasBox.Margin = new System.Windows.Forms.Padding(4); + this.camerasBox.Location = new System.Drawing.Point(14, 186); this.camerasBox.Name = "camerasBox"; - this.camerasBox.Size = new System.Drawing.Size(86, 20); + this.camerasBox.Size = new System.Drawing.Size(66, 16); this.camerasBox.TabIndex = 2; this.camerasBox.Text = "Cameras"; this.camerasBox.UseVisualStyleBackColor = true; @@ -132,10 +125,9 @@ // exportDeformers // this.exportDeformers.AutoSize = true; - this.exportDeformers.Location = new System.Drawing.Point(19, 178); - this.exportDeformers.Margin = new System.Windows.Forms.Padding(4); + this.exportDeformers.Location = new System.Drawing.Point(14, 142); this.exportDeformers.Name = "exportDeformers"; - this.exportDeformers.Size = new System.Drawing.Size(142, 20); + this.exportDeformers.Size = new System.Drawing.Size(108, 16); this.exportDeformers.TabIndex = 1; this.exportDeformers.Text = "Skin Deformers"; this.exportDeformers.UseVisualStyleBackColor = true; @@ -148,11 +140,9 @@ this.geometryBox.Controls.Add(this.exportUVs); this.geometryBox.Controls.Add(this.exportTangents); this.geometryBox.Controls.Add(this.exportNormals); - this.geometryBox.Location = new System.Drawing.Point(9, 22); - this.geometryBox.Margin = new System.Windows.Forms.Padding(4); + this.geometryBox.Location = new System.Drawing.Point(7, 18); this.geometryBox.Name = "geometryBox"; - this.geometryBox.Padding = new System.Windows.Forms.Padding(4); - this.geometryBox.Size = new System.Drawing.Size(313, 152); + this.geometryBox.Size = new System.Drawing.Size(235, 122); this.geometryBox.TabIndex = 0; this.geometryBox.TabStop = false; this.geometryBox.Text = "Geometry"; @@ -162,10 +152,9 @@ this.exportColors.AutoSize = true; this.exportColors.Checked = true; this.exportColors.CheckState = System.Windows.Forms.CheckState.Checked; - this.exportColors.Location = new System.Drawing.Point(9, 106); - this.exportColors.Margin = new System.Windows.Forms.Padding(4); + this.exportColors.Location = new System.Drawing.Point(7, 85); this.exportColors.Name = "exportColors"; - this.exportColors.Size = new System.Drawing.Size(134, 20); + this.exportColors.Size = new System.Drawing.Size(102, 16); this.exportColors.TabIndex = 3; this.exportColors.Text = "Vertex Colors"; this.exportColors.UseVisualStyleBackColor = true; @@ -176,10 +165,9 @@ this.exportUVs.AutoSize = true; this.exportUVs.Checked = true; this.exportUVs.CheckState = System.Windows.Forms.CheckState.Checked; - this.exportUVs.Location = new System.Drawing.Point(9, 79); - this.exportUVs.Margin = new System.Windows.Forms.Padding(4); + this.exportUVs.Location = new System.Drawing.Point(7, 63); this.exportUVs.Name = "exportUVs"; - this.exportUVs.Size = new System.Drawing.Size(142, 20); + this.exportUVs.Size = new System.Drawing.Size(108, 16); this.exportUVs.TabIndex = 2; this.exportUVs.Text = "UV Coordinates"; this.exportUVs.UseVisualStyleBackColor = true; @@ -188,10 +176,9 @@ // exportTangents // this.exportTangents.AutoSize = true; - this.exportTangents.Location = new System.Drawing.Point(9, 51); - this.exportTangents.Margin = new System.Windows.Forms.Padding(4); + this.exportTangents.Location = new System.Drawing.Point(7, 41); this.exportTangents.Name = "exportTangents"; - this.exportTangents.Size = new System.Drawing.Size(94, 20); + this.exportTangents.Size = new System.Drawing.Size(72, 16); this.exportTangents.TabIndex = 1; this.exportTangents.Text = "Tangents"; this.exportTangents.UseVisualStyleBackColor = true; @@ -202,10 +189,9 @@ this.exportNormals.AutoSize = true; this.exportNormals.Checked = true; this.exportNormals.CheckState = System.Windows.Forms.CheckState.Checked; - this.exportNormals.Location = new System.Drawing.Point(9, 22); - this.exportNormals.Margin = new System.Windows.Forms.Padding(4); + this.exportNormals.Location = new System.Drawing.Point(7, 18); this.exportNormals.Name = "exportNormals"; - this.exportNormals.Size = new System.Drawing.Size(86, 20); + this.exportNormals.Size = new System.Drawing.Size(66, 16); this.exportNormals.TabIndex = 0; this.exportNormals.Text = "Normals"; this.exportNormals.UseVisualStyleBackColor = true; @@ -218,11 +204,9 @@ this.advancedBox.Controls.Add(this.upAxis); this.advancedBox.Controls.Add(this.scaleFactor); this.advancedBox.Controls.Add(this.scaleLabel); - this.advancedBox.Location = new System.Drawing.Point(16, 355); - this.advancedBox.Margin = new System.Windows.Forms.Padding(4); + this.advancedBox.Location = new System.Drawing.Point(12, 284); this.advancedBox.Name = "advancedBox"; - this.advancedBox.Padding = new System.Windows.Forms.Padding(4); - this.advancedBox.Size = new System.Drawing.Size(332, 96); + this.advancedBox.Size = new System.Drawing.Size(249, 78); this.advancedBox.TabIndex = 5; this.advancedBox.TabStop = false; this.advancedBox.Text = "Advanced Options"; @@ -230,10 +214,9 @@ // axisLabel // this.axisLabel.AutoSize = true; - this.axisLabel.Location = new System.Drawing.Point(8, 50); - this.axisLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.axisLabel.Location = new System.Drawing.Point(6, 40); this.axisLabel.Name = "axisLabel"; - this.axisLabel.Size = new System.Drawing.Size(72, 16); + this.axisLabel.Size = new System.Drawing.Size(53, 12); this.axisLabel.TabIndex = 3; this.axisLabel.Text = "Up Axis:"; // @@ -242,11 +225,10 @@ this.upAxis.FormattingEnabled = true; this.upAxis.Items.AddRange(new object[] { "Y-up"}); - this.upAxis.Location = new System.Drawing.Point(88, 47); - this.upAxis.Margin = new System.Windows.Forms.Padding(4); + this.upAxis.Location = new System.Drawing.Point(66, 38); this.upAxis.MaxDropDownItems = 2; this.upAxis.Name = "upAxis"; - this.upAxis.Size = new System.Drawing.Size(92, 23); + this.upAxis.Size = new System.Drawing.Size(70, 20); this.upAxis.TabIndex = 2; // // scaleFactor @@ -257,10 +239,9 @@ 0, 0, 131072}); - this.scaleFactor.Location = new System.Drawing.Point(128, 17); - this.scaleFactor.Margin = new System.Windows.Forms.Padding(4); + this.scaleFactor.Location = new System.Drawing.Point(96, 14); this.scaleFactor.Name = "scaleFactor"; - this.scaleFactor.Size = new System.Drawing.Size(61, 25); + this.scaleFactor.Size = new System.Drawing.Size(46, 21); this.scaleFactor.TabIndex = 1; this.scaleFactor.Value = new decimal(new int[] { 254, @@ -271,19 +252,17 @@ // scaleLabel // this.scaleLabel.AutoSize = true; - this.scaleLabel.Location = new System.Drawing.Point(8, 19); - this.scaleLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.scaleLabel.Location = new System.Drawing.Point(6, 15); this.scaleLabel.Name = "scaleLabel"; - this.scaleLabel.Size = new System.Drawing.Size(112, 16); + this.scaleLabel.Size = new System.Drawing.Size(83, 12); this.scaleLabel.TabIndex = 0; this.scaleLabel.Text = "Scale Factor:"; // // fbxOKbutton // - this.fbxOKbutton.Location = new System.Drawing.Point(443, 455); - this.fbxOKbutton.Margin = new System.Windows.Forms.Padding(4); + this.fbxOKbutton.Location = new System.Drawing.Point(332, 364); this.fbxOKbutton.Name = "fbxOKbutton"; - this.fbxOKbutton.Size = new System.Drawing.Size(100, 26); + this.fbxOKbutton.Size = new System.Drawing.Size(75, 21); this.fbxOKbutton.TabIndex = 6; this.fbxOKbutton.Text = "OK"; this.fbxOKbutton.UseVisualStyleBackColor = true; @@ -292,76 +271,64 @@ // fbxCancel // this.fbxCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.fbxCancel.Location = new System.Drawing.Point(560, 455); - this.fbxCancel.Margin = new System.Windows.Forms.Padding(4); + this.fbxCancel.Location = new System.Drawing.Point(420, 364); this.fbxCancel.Name = "fbxCancel"; - this.fbxCancel.Size = new System.Drawing.Size(100, 26); + this.fbxCancel.Size = new System.Drawing.Size(75, 21); this.fbxCancel.TabIndex = 7; this.fbxCancel.Text = "Cancel"; this.fbxCancel.UseVisualStyleBackColor = true; this.fbxCancel.Click += new System.EventHandler(this.fbxCancel_Click); // - // saveFileDialog1 - // - this.saveFileDialog1.Filter = "FBX file|*.fbx|Collada|*.dae"; - this.saveFileDialog1.RestoreDirectory = true; - // // showExpOpt // this.showExpOpt.AutoSize = true; - this.showExpOpt.Location = new System.Drawing.Point(16, 459); - this.showExpOpt.Margin = new System.Windows.Forms.Padding(4); + this.showExpOpt.Location = new System.Drawing.Point(12, 367); this.showExpOpt.Name = "showExpOpt"; - this.showExpOpt.Size = new System.Drawing.Size(294, 20); + this.showExpOpt.Size = new System.Drawing.Size(222, 16); this.showExpOpt.TabIndex = 8; this.showExpOpt.Text = "Show this dialog for every export"; this.showExpOpt.UseVisualStyleBackColor = true; // // groupBox1 // - this.groupBox1.Controls.Add(this.convertfsb); + this.groupBox1.Controls.Add(this.convertAudio); this.groupBox1.Controls.Add(this.panel1); this.groupBox1.Controls.Add(this.converttexture); - this.groupBox1.Location = new System.Drawing.Point(356, 15); - this.groupBox1.Margin = new System.Windows.Forms.Padding(4); + this.groupBox1.Location = new System.Drawing.Point(267, 12); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Padding = new System.Windows.Forms.Padding(4); - this.groupBox1.Size = new System.Drawing.Size(304, 436); + this.groupBox1.Size = new System.Drawing.Size(228, 349); this.groupBox1.TabIndex = 9; this.groupBox1.TabStop = false; this.groupBox1.Text = "Convert"; // - // convertfsb + // convertAudio // - this.convertfsb.AutoSize = true; - this.convertfsb.Checked = true; - this.convertfsb.CheckState = System.Windows.Forms.CheckState.Checked; - this.convertfsb.Location = new System.Drawing.Point(11, 101); - this.convertfsb.Margin = new System.Windows.Forms.Padding(4); - this.convertfsb.Name = "convertfsb"; - this.convertfsb.Size = new System.Drawing.Size(174, 20); - this.convertfsb.TabIndex = 6; - this.convertfsb.Text = "Convert FSB to WAV"; - this.convertfsb.UseVisualStyleBackColor = true; + this.convertAudio.AutoSize = true; + this.convertAudio.Checked = true; + this.convertAudio.CheckState = System.Windows.Forms.CheckState.Checked; + this.convertAudio.Location = new System.Drawing.Point(8, 81); + this.convertAudio.Name = "convertAudio"; + this.convertAudio.Size = new System.Drawing.Size(198, 28); + this.convertAudio.TabIndex = 6; + this.convertAudio.Text = "Convert AudioClip to WAV(PCM)\r\n(If support)"; + this.convertAudio.UseVisualStyleBackColor = true; // // panel1 // this.panel1.Controls.Add(this.tojpg); this.panel1.Controls.Add(this.topng); this.panel1.Controls.Add(this.tobmp); - this.panel1.Location = new System.Drawing.Point(40, 52); - this.panel1.Margin = new System.Windows.Forms.Padding(4); + this.panel1.Location = new System.Drawing.Point(30, 42); this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(195, 38); + this.panel1.Size = new System.Drawing.Size(146, 30); this.panel1.TabIndex = 5; // // tojpg // this.tojpg.AutoSize = true; - this.tojpg.Location = new System.Drawing.Point(129, 8); - this.tojpg.Margin = new System.Windows.Forms.Padding(4); + this.tojpg.Location = new System.Drawing.Point(97, 6); this.tojpg.Name = "tojpg"; - this.tojpg.Size = new System.Drawing.Size(61, 20); + this.tojpg.Size = new System.Drawing.Size(47, 16); this.tojpg.TabIndex = 4; this.tojpg.Text = "JPEG"; this.tojpg.UseVisualStyleBackColor = true; @@ -370,10 +337,9 @@ // this.topng.AutoSize = true; this.topng.Checked = true; - this.topng.Location = new System.Drawing.Point(67, 8); - this.topng.Margin = new System.Windows.Forms.Padding(4); + this.topng.Location = new System.Drawing.Point(50, 6); this.topng.Name = "topng"; - this.topng.Size = new System.Drawing.Size(53, 20); + this.topng.Size = new System.Drawing.Size(41, 16); this.topng.TabIndex = 3; this.topng.TabStop = true; this.topng.Text = "PNG"; @@ -382,10 +348,9 @@ // tobmp // this.tobmp.AutoSize = true; - this.tobmp.Location = new System.Drawing.Point(4, 8); - this.tobmp.Margin = new System.Windows.Forms.Padding(4); + this.tobmp.Location = new System.Drawing.Point(3, 6); this.tobmp.Name = "tobmp"; - this.tobmp.Size = new System.Drawing.Size(53, 20); + this.tobmp.Size = new System.Drawing.Size(41, 16); this.tobmp.TabIndex = 2; this.tobmp.Text = "BMP"; this.tobmp.UseVisualStyleBackColor = true; @@ -395,10 +360,9 @@ this.converttexture.AutoSize = true; this.converttexture.Checked = true; this.converttexture.CheckState = System.Windows.Forms.CheckState.Checked; - this.converttexture.Location = new System.Drawing.Point(11, 25); - this.converttexture.Margin = new System.Windows.Forms.Padding(4); + this.converttexture.Location = new System.Drawing.Point(8, 20); this.converttexture.Name = "converttexture"; - this.converttexture.Size = new System.Drawing.Size(254, 20); + this.converttexture.Size = new System.Drawing.Size(192, 16); this.converttexture.TabIndex = 1; this.converttexture.Text = "Convert Texture (If support)"; this.converttexture.UseVisualStyleBackColor = true; @@ -406,17 +370,16 @@ // ExportOptions // this.AcceptButton = this.fbxOKbutton; - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F); + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.fbxCancel; - this.ClientSize = new System.Drawing.Size(684, 490); + this.ClientSize = new System.Drawing.Size(513, 392); this.Controls.Add(this.groupBox1); this.Controls.Add(this.showExpOpt); this.Controls.Add(this.fbxCancel); this.Controls.Add(this.fbxOKbutton); this.Controls.Add(this.advancedBox); this.Controls.Add(this.includeBox); - this.Margin = new System.Windows.Forms.Padding(4); this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "ExportOptions"; @@ -460,7 +423,6 @@ private System.Windows.Forms.ComboBox upAxis; private System.Windows.Forms.Button fbxOKbutton; private System.Windows.Forms.Button fbxCancel; - private System.Windows.Forms.SaveFileDialog saveFileDialog1; private System.Windows.Forms.CheckBox showExpOpt; private System.Windows.Forms.CheckBox convertDummies; private System.Windows.Forms.GroupBox groupBox1; @@ -468,7 +430,7 @@ private System.Windows.Forms.RadioButton tojpg; private System.Windows.Forms.RadioButton topng; private System.Windows.Forms.RadioButton tobmp; - private System.Windows.Forms.CheckBox convertfsb; + private System.Windows.Forms.CheckBox convertAudio; private System.Windows.Forms.Panel panel1; } } \ No newline at end of file diff --git a/Unity Studio/ExportOptions.cs b/Unity Studio/ExportOptions.cs index 709deae..86dcf14 100644 --- a/Unity Studio/ExportOptions.cs +++ b/Unity Studio/ExportOptions.cs @@ -26,7 +26,7 @@ namespace Unity_Studio upAxis.SelectedIndex = (int)Properties.Settings.Default["upAxis"]; showExpOpt.Checked = (bool)Properties.Settings.Default["showExpOpt"]; converttexture.Checked = (bool)Properties.Settings.Default["convertTexture"]; - convertfsb.Checked = (bool)Properties.Settings.Default["convertfsb"]; + convertAudio.Checked = (bool)Properties.Settings.Default["convertAudio"]; var str = (string)Properties.Settings.Default["convertType"]; foreach (Control c in panel1.Controls) { @@ -54,7 +54,7 @@ namespace Unity_Studio Properties.Settings.Default["scaleFactor"] = scaleFactor.Value; Properties.Settings.Default["upAxis"] = upAxis.SelectedIndex; Properties.Settings.Default["convertTexture"] = converttexture.Checked; - Properties.Settings.Default["convertfsb"] = convertfsb.Checked; + Properties.Settings.Default["convertAudio"] = convertAudio.Checked; foreach (Control c in panel1.Controls) { if (((RadioButton)c).Checked) diff --git a/Unity Studio/ExportOptions.resx b/Unity Studio/ExportOptions.resx index 053da59..1af7de1 100644 --- a/Unity Studio/ExportOptions.resx +++ b/Unity Studio/ExportOptions.resx @@ -117,7 +117,4 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 17, 17 - \ No newline at end of file diff --git a/Unity Studio/Properties/Settings.Designer.cs b/Unity Studio/Properties/Settings.Designer.cs index e8e1740..d5358d5 100644 --- a/Unity Studio/Properties/Settings.Designer.cs +++ b/Unity Studio/Properties/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace Unity_Studio.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.5.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); @@ -206,12 +206,12 @@ namespace Unity_Studio.Properties { [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("True")] - public bool convertfsb { + public bool convertAudio { get { - return ((bool)(this["convertfsb"])); + return ((bool)(this["convertAudio"])); } set { - this["convertfsb"] = value; + this["convertAudio"] = value; } } diff --git a/Unity Studio/Properties/Settings.settings b/Unity Studio/Properties/Settings.settings index 77ab853..e5e6311 100644 --- a/Unity Studio/Properties/Settings.settings +++ b/Unity Studio/Properties/Settings.settings @@ -47,7 +47,7 @@ True - + True diff --git a/Unity Studio/Unity Classes/AudioClip.cs b/Unity Studio/Unity Classes/AudioClip.cs index f8c9a44..5050048 100644 --- a/Unity Studio/Unity Classes/AudioClip.cs +++ b/Unity Studio/Unity Classes/AudioClip.cs @@ -11,7 +11,7 @@ namespace Unity_Studio { public string m_Name; public int m_Format; - public int m_Type = -1; + public AudioType m_Type; public bool m_3D; public bool m_UseHardware; @@ -26,13 +26,15 @@ namespace Unity_Studio public bool m_PreloadAudioData; public bool m_LoadInBackground; public bool m_Legacy3D; - public int m_CompressionFormat = -1; + public AudioCompressionFormat m_CompressionFormat; public string m_Source; public long m_Offset; public long m_Size; public byte[] m_AudioData; + public bool version5; + public AudioClip(AssetPreloadData preloadData, bool readSwitch) { var sourceFile = preloadData.sourceFile; @@ -47,12 +49,12 @@ namespace Unity_Studio } m_Name = a_Stream.ReadAlignedString(a_Stream.ReadInt32()); - + version5 = sourceFile.version[0] >= 5; if (sourceFile.version[0] < 5) { m_Format = a_Stream.ReadInt32(); //channels? - m_Type = a_Stream.ReadInt32(); + m_Type = (AudioType)a_Stream.ReadInt32(); m_3D = a_Stream.ReadBoolean(); m_UseHardware = a_Stream.ReadBoolean(); a_Stream.Position += 2; //4 byte alignment @@ -69,11 +71,14 @@ namespace Unity_Studio m_Source = sourceFile.filePath + ".resS"; } } - else { m_Size = a_Stream.ReadInt32(); } + else + { + m_Size = a_Stream.ReadInt32(); + } } else { - m_LoadType = a_Stream.ReadInt32();//Decompress on load, Compressed in memory, Streaming + m_LoadType = a_Stream.ReadInt32(); //Decompress on load, Compressed in memory, Streaming m_Channels = a_Stream.ReadInt32(); m_Frequency = a_Stream.ReadInt32(); m_BitsPerSample = a_Stream.ReadInt32(); @@ -92,7 +97,7 @@ namespace Unity_Studio m_Source = Path.Combine(Path.GetDirectoryName(sourceFile.filePath), m_Source.Replace("archive:/", "")); m_Offset = a_Stream.ReadInt64(); m_Size = a_Stream.ReadInt64(); - m_CompressionFormat = a_Stream.ReadInt32(); + m_CompressionFormat = (AudioCompressionFormat)a_Stream.ReadInt32(); } if (readSwitch) @@ -103,7 +108,7 @@ namespace Unity_Studio m_AudioData = a_Stream.ReadBytes((int)m_Size); } else if (File.Exists(m_Source) || - File.Exists(m_Source = Path.Combine(Path.GetDirectoryName(sourceFile.filePath), Path.GetFileName(m_Source)))) + File.Exists(m_Source = Path.Combine(Path.GetDirectoryName(sourceFile.filePath), Path.GetFileName(m_Source)))) { BinaryReader reader = new BinaryReader(File.OpenRead(m_Source)); reader.BaseStream.Position = m_Offset; @@ -127,52 +132,106 @@ namespace Unity_Studio { preloadData.InfoText = "Compression format: "; - switch (m_Type) + if (sourceFile.version[0] < 5) { - case 2: - preloadData.extension = ".aif"; - preloadData.InfoText += "AIFF"; - break; - case 13: - preloadData.extension = ".mp3"; - preloadData.InfoText += "MP3"; - break; - case 14: - preloadData.extension = ".ogg"; - preloadData.InfoText += "Ogg Vorbis"; - break; - case 20: - preloadData.extension = ".wav"; - preloadData.InfoText += "WAV"; - break; - case 22: //xbox encoding - preloadData.extension = ".wav"; - preloadData.InfoText += "Xbox360 WAV"; - break; - } + switch (m_Type) + { + case AudioType.ACC: + preloadData.extension = ".m4a"; + preloadData.InfoText += "Acc"; + break; + case AudioType.AIFF: + preloadData.extension = ".aif"; + preloadData.InfoText += "AIFF"; + break; + case AudioType.IT: + preloadData.extension = ".it"; + preloadData.InfoText += "Impulse tracker"; + break; + case AudioType.MOD: + preloadData.extension = ".mod"; + preloadData.InfoText += "Protracker / Fasttracker MOD"; + break; + case AudioType.MPEG: + preloadData.extension = ".mp3"; + preloadData.InfoText += "MP2/MP3 MPEG"; + break; + case AudioType.OGGVORBIS: + preloadData.extension = ".ogg"; + preloadData.InfoText += "Ogg vorbis"; + break; + case AudioType.S3M: + preloadData.extension = ".s3m"; + preloadData.InfoText += "ScreamTracker 3"; + break; + case AudioType.WAV: + preloadData.extension = ".wav"; + preloadData.InfoText += "Microsoft WAV"; + break; + case AudioType.XM: + preloadData.extension = ".xm"; + preloadData.InfoText += "FastTracker 2 XM"; + break; + case AudioType.XMA: + preloadData.extension = ".wav"; + preloadData.InfoText += "Xbox360 XMA"; + break; + case AudioType.VAG: + preloadData.extension = ".vag"; + preloadData.InfoText += "PlayStation Portable ADPCM"; + break; + case AudioType.AUDIOQUEUE: + preloadData.extension = ".fsb"; + preloadData.InfoText += "iPhone"; + break; + } - switch (m_CompressionFormat) + } + else { - case 0: - preloadData.extension = ".fsb"; - preloadData.InfoText += "PCM"; - break; - case 1: - preloadData.extension = ".fsb"; - preloadData.InfoText += "Vorbis"; - break; - case 2: - preloadData.extension = ".fsb"; - preloadData.InfoText += "ADPCM"; - break; - case 3: - preloadData.extension = ".fsb"; - preloadData.InfoText += "MP3";//not sure - break; - case 7: - preloadData.extension = ".m4a"; - preloadData.InfoText += "M4a"; - break; + switch (m_CompressionFormat) + { + case AudioCompressionFormat.PCM: + preloadData.extension = ".fsb"; + preloadData.InfoText += "PCM"; + break; + case AudioCompressionFormat.Vorbis: + preloadData.extension = ".fsb"; + preloadData.InfoText += "Vorbis"; + break; + case AudioCompressionFormat.ADPCM: + preloadData.extension = ".fsb"; + preloadData.InfoText += "ADPCM"; + break; + case AudioCompressionFormat.MP3: + preloadData.extension = ".fsb"; + preloadData.InfoText += "MP3"; + break; + case AudioCompressionFormat.VAG: + preloadData.extension = ".vag"; + preloadData.InfoText += "PlayStation Portable ADPCM"; + break; + case AudioCompressionFormat.HEVAG: + preloadData.extension = ".vag"; + preloadData.InfoText += "PSVita ADPCM"; + break; + case AudioCompressionFormat.XMA: + preloadData.extension = ".wav"; + preloadData.InfoText += "Xbox360 XMA"; + break; + case AudioCompressionFormat.AAC: + preloadData.extension = ".m4a"; + preloadData.InfoText += "Acc"; + break; + case AudioCompressionFormat.GCADPCM: + preloadData.extension = ".fsb"; + preloadData.InfoText += "Nintendo 3DS/Wii DSP"; + break; + case AudioCompressionFormat.ATRAC9: + preloadData.extension = ".at9"; + preloadData.InfoText += "PSVita ATRAC9"; + break; + } } if (preloadData.extension == null) @@ -180,6 +239,7 @@ namespace Unity_Studio preloadData.extension = ".AudioClip"; preloadData.InfoText += "Unknown"; } + preloadData.InfoText += "\n3D: " + m_3D; preloadData.Text = m_Name; @@ -187,5 +247,47 @@ namespace Unity_Studio preloadData.fullSize = preloadData.Size + (int)m_Size; } } + + public bool IsFMODSupport + { + get + { + if (!version5) + { + switch (m_Type) + { + case AudioType.AIFF: + case AudioType.IT: + case AudioType.MOD: + case AudioType.S3M: + case AudioType.XM: + case AudioType.XMA: + case AudioType.VAG: + case AudioType.AUDIOQUEUE: + return true; + default: + return false; + } + } + else + { + switch (m_CompressionFormat) + { + case AudioCompressionFormat.PCM: + case AudioCompressionFormat.Vorbis: + case AudioCompressionFormat.ADPCM: + case AudioCompressionFormat.MP3: + case AudioCompressionFormat.VAG: + case AudioCompressionFormat.HEVAG: + case AudioCompressionFormat.XMA: + case AudioCompressionFormat.GCADPCM: + case AudioCompressionFormat.ATRAC9: + return true; + default: + return false; + } + } + } + } } } diff --git a/Unity Studio/Unity Classes/Texture2D.cs b/Unity Studio/Unity Classes/Texture2D.cs index bfd2018..31d6745 100644 --- a/Unity Studio/Unity Classes/Texture2D.cs +++ b/Unity Studio/Unity Classes/Texture2D.cs @@ -1093,67 +1093,6 @@ namespace Unity_Studio } } -public enum TextureFormat -{ - Alpha8 = 1, - ARGB4444, - RGB24, - RGBA32, - ARGB32, - RGB565 = 7, - R16 = 9, - DXT1, - DXT5 = 12, - RGBA4444, - BGRA32, - RHalf, - RGHalf, - RGBAHalf, - RFloat, - RGFloat, - RGBAFloat, - YUY2, - RGB9e5Float, - BC4 = 26, - BC5, - BC6H = 24, - BC7, - DXT1Crunched = 28, - DXT5Crunched, - PVRTC_RGB2, - PVRTC_RGBA2, - PVRTC_RGB4, - PVRTC_RGBA4, - ETC_RGB4, - ATC_RGB4, - ATC_RGBA8, - EAC_R = 41, - EAC_R_SIGNED, - EAC_RG, - EAC_RG_SIGNED, - ETC2_RGB, - ETC2_RGBA1, - ETC2_RGBA8, - ASTC_RGB_4x4, - ASTC_RGB_5x5, - ASTC_RGB_6x6, - ASTC_RGB_8x8, - ASTC_RGB_10x10, - ASTC_RGB_12x12, - ASTC_RGBA_4x4, - ASTC_RGBA_5x5, - ASTC_RGBA_6x6, - ASTC_RGBA_8x8, - ASTC_RGBA_10x10, - ASTC_RGBA_12x12, - ETC_RGB4_3DS, - ETC_RGBA8_3DS, - RG16, - R8, - ETC_RGB4Crunched, - ETC2_RGBA8Crunched, -} - public static class KTXHeader { public static byte[] IDENTIFIER = { 0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A }; diff --git a/Unity Studio/Unity Studio Classes/UnityEnum.cs b/Unity Studio/Unity Studio Classes/UnityEnum.cs new file mode 100644 index 0000000..92e4835 --- /dev/null +++ b/Unity Studio/Unity Studio Classes/UnityEnum.cs @@ -0,0 +1,99 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Unity_Studio +{ + public enum TextureFormat + { + Alpha8 = 1, + ARGB4444, + RGB24, + RGBA32, + ARGB32, + RGB565 = 7, + R16 = 9, + DXT1, + DXT5 = 12, + RGBA4444, + BGRA32, + RHalf, + RGHalf, + RGBAHalf, + RFloat, + RGFloat, + RGBAFloat, + YUY2, + RGB9e5Float, + BC4 = 26, + BC5, + BC6H = 24, + BC7, + DXT1Crunched = 28, + DXT5Crunched, + PVRTC_RGB2, + PVRTC_RGBA2, + PVRTC_RGB4, + PVRTC_RGBA4, + ETC_RGB4, + ATC_RGB4, + ATC_RGBA8, + EAC_R = 41, + EAC_R_SIGNED, + EAC_RG, + EAC_RG_SIGNED, + ETC2_RGB, + ETC2_RGBA1, + ETC2_RGBA8, + ASTC_RGB_4x4, + ASTC_RGB_5x5, + ASTC_RGB_6x6, + ASTC_RGB_8x8, + ASTC_RGB_10x10, + ASTC_RGB_12x12, + ASTC_RGBA_4x4, + ASTC_RGBA_5x5, + ASTC_RGBA_6x6, + ASTC_RGBA_8x8, + ASTC_RGBA_10x10, + ASTC_RGBA_12x12, + ETC_RGB4_3DS, + ETC_RGBA8_3DS, + RG16, + R8, + ETC_RGB4Crunched, + ETC2_RGBA8Crunched, + } + + public enum AudioType + { + UNKNOWN, + ACC, + AIFF, + IT = 10, + MOD = 12, + MPEG, + OGGVORBIS, + S3M = 17, + WAV = 20, + XM, + XMA, + VAG, + AUDIOQUEUE + } + + public enum AudioCompressionFormat + { + PCM, + Vorbis, + ADPCM, + MP3, + VAG, + HEVAG, + XMA, + AAC, + GCADPCM, + ATRAC9 + } +} diff --git a/Unity Studio/Unity Studio Classes/UnityStudio.cs b/Unity Studio/Unity Studio Classes/UnityStudio.cs index 527a524..f8d0ba4 100644 --- a/Unity Studio/Unity Studio Classes/UnityStudio.cs +++ b/Unity Studio/Unity Studio Classes/UnityStudio.cs @@ -1621,49 +1621,40 @@ namespace Unity_Studio var m_AudioClip = new AudioClip(asset, true); if (m_AudioClip.m_AudioData == null) return false; - var oldextension = asset.extension; - var exportFileExtension = asset.extension; - var convertfsb = (bool)Properties.Settings.Default["convertfsb"]; - if (convertfsb && exportFileExtension == ".fsb") - { - exportFileExtension = ".wav"; - } - var exportFullName = exportPath + asset.Text + exportFileExtension; - if (ExportFileExists(exportFullName)) - return false; - if (convertfsb && oldextension == ".fsb") + var convertAudio = (bool)Properties.Settings.Default["convertAudio"]; + if (convertAudio && m_AudioClip.IsFMODSupport) { + var exportFullName = exportPath + asset.Text + ".wav"; + if (ExportFileExists(exportFullName)) + return false; FMOD.CREATESOUNDEXINFO exinfo = new FMOD.CREATESOUNDEXINFO(); - var result = FMOD.Factory.System_Create(out var system); - if (result != FMOD.RESULT.OK) { return false; } - + if (result != FMOD.RESULT.OK) + return false; result = system.init(1, FMOD.INITFLAGS.NORMAL, IntPtr.Zero); - if (result != FMOD.RESULT.OK) { return false; } - + if (result != FMOD.RESULT.OK) + return false; exinfo.cbsize = Marshal.SizeOf(exinfo); exinfo.length = (uint)m_AudioClip.m_Size; - result = system.createSound(m_AudioClip.m_AudioData, FMOD.MODE.OPENMEMORY, ref exinfo, out var sound); - if (result != FMOD.RESULT.OK) { return false; } - + if (result != FMOD.RESULT.OK) + return false; result = sound.getSubSound(0, out var subsound); - if (result != FMOD.RESULT.OK) { return false; } - + if (result != FMOD.RESULT.OK) + return false; result = subsound.getFormat(out var type, out var format, out int NumChannels, out int BitsPerSample); - if (result != FMOD.RESULT.OK) { return false; } - + if (result != FMOD.RESULT.OK) + return false; result = subsound.getDefaults(out var frequency, out int priority); - if (result != FMOD.RESULT.OK) { return false; } - + if (result != FMOD.RESULT.OK) + return false; var SampleRate = (int)frequency; - result = subsound.getLength(out var length, FMOD.TIMEUNIT.PCMBYTES); - if (result != FMOD.RESULT.OK) { return false; } - + if (result != FMOD.RESULT.OK) + return false; result = subsound.@lock(0, length, out var ptr1, out var ptr2, out var len1, out var len2); - if (result != FMOD.RESULT.OK) { return false; } - + if (result != FMOD.RESULT.OK) + return false; byte[] buffer = new byte[len1 + 44]; //添加wav头 Encoding.UTF8.GetBytes("RIFF").CopyTo(buffer, 0); @@ -1680,16 +1671,18 @@ namespace Unity_Studio BitConverter.GetBytes(len1).CopyTo(buffer, 40); Marshal.Copy(ptr1, buffer, 44, (int)len1); File.WriteAllBytes(exportFullName, buffer); - result = subsound.unlock(ptr1, ptr2, len1, len2); - if (result != FMOD.RESULT.OK) { return false; } - + if (result != FMOD.RESULT.OK) + return false; subsound.release(); sound.release(); system.release(); } else { + var exportFullName = exportPath + asset.Text + asset.extension; + if (ExportFileExists(exportFullName)) + return false; File.WriteAllBytes(exportFullName, m_AudioClip.m_AudioData); } return true; diff --git a/Unity Studio/Unity Studio-x86.csproj b/Unity Studio/Unity Studio-x86.csproj index 4b23aad..3ead8c2 100644 --- a/Unity Studio/Unity Studio-x86.csproj +++ b/Unity Studio/Unity Studio-x86.csproj @@ -147,6 +147,7 @@ + diff --git a/Unity Studio/Unity Studio.csproj b/Unity Studio/Unity Studio.csproj index 42abe1a..04514f5 100644 --- a/Unity Studio/Unity Studio.csproj +++ b/Unity Studio/Unity Studio.csproj @@ -146,6 +146,7 @@ + @@ -207,7 +208,9 @@ UnityStudioForm.cs Designer - + + Designer + SettingsSingleFileGenerator Settings.Designer.cs diff --git a/Unity Studio/app.config b/Unity Studio/app.config index 9102bd1..4c94ffa 100644 --- a/Unity Studio/app.config +++ b/Unity Studio/app.config @@ -52,7 +52,7 @@ True - + True