From 4b8b8fb8ea8b3b8a3c3c0c5c7e4fedcac7e5b0a5 Mon Sep 17 00:00:00 2001 From: Perfare Date: Tue, 25 Oct 2016 18:40:09 +0800 Subject: [PATCH] fixed some bug --- Unity Studio/Unity Classes/Texture2D.cs | 16 +++----------- Unity Studio/UnityStudioForm.cs | 28 ++++++++----------------- 2 files changed, 12 insertions(+), 32 deletions(-) diff --git a/Unity Studio/Unity Classes/Texture2D.cs b/Unity Studio/Unity Classes/Texture2D.cs index feb7934..e75cb4f 100644 --- a/Unity Studio/Unity Classes/Texture2D.cs +++ b/Unity Studio/Unity Classes/Texture2D.cs @@ -191,7 +191,7 @@ namespace Unity_Studio dwRBitMask = 0x0; dwGBitMask = 0x0; dwBBitMask = 0x0; - dwABitMask = 0x0; *///透明通道丢失? + dwABitMask = 0xFF; *///透明通道丢失? //转ARGB32 var bytes = Enumerable.Repeat(0xFF, image_data_size * 4).ToArray(); for (int i = 0; i < image_data_size; i++) @@ -281,7 +281,7 @@ namespace Unity_Studio } case TextureFormat.R16: break; - case TextureFormat.DXT1: //DXT1 + case TextureFormat.DXT1: //test pass { if (sourceFile.platform == 11) //X360 only, PS3 not { @@ -303,7 +303,7 @@ namespace Unity_Studio dwABitMask = 0x0; break; } - case TextureFormat.DXT5: //DXT5 + case TextureFormat.DXT5: //test pass { if (sourceFile.platform == 11) //X360, PS3 not { @@ -687,14 +687,4 @@ public class KTXHeader public static int GL_RGB = 0x1907; public static int GL_RGBA = 0x1908; public static int GL_RG = 0x8227; - - public static int getMipMapCount(int width, int height) - { - int mipMapCount = 1; - for (int dim = Math.Max(width, height); dim > 1; dim /= 2) - { - mipMapCount++; - } - return mipMapCount; - } } \ No newline at end of file diff --git a/Unity Studio/UnityStudioForm.cs b/Unity Studio/UnityStudioForm.cs index 7a2f993..d000623 100644 --- a/Unity Studio/UnityStudioForm.cs +++ b/Unity Studio/UnityStudioForm.cs @@ -768,7 +768,7 @@ namespace Unity_Studio } if (exportable) { - if (!exportableAssetsHash.Add(asset.TypeString + asset.Text)) + if (!exportableAssetsHash.Add((asset.TypeString + asset.Text).ToUpper())) { asset.Text += " #" + asset.uniqueID; } @@ -3127,8 +3127,9 @@ namespace Unity_Studio private bool ExportTexture(AssetPreloadData asset, string exportFilename, string exportFileextension, bool flip) { ImageFormat format = null; + var convert = (bool)Properties.Settings.Default["convertTexture"]; var oldextension = exportFileextension; - if ((bool)Properties.Settings.Default["convertTexture"]) + if (convert && (exportFileextension == ".dds" || exportFileextension == ".pvr" || exportFileextension == ".astc")) { string str = Properties.Settings.Default["convertType"] as string; exportFileextension = "." + str.ToLower(); @@ -3140,18 +3141,13 @@ namespace Unity_Studio format = ImageFormat.Jpeg; } var exportFullname = exportFilename + exportFileextension; - if (File.Exists(exportFullname)) - { - StatusStripUpdate("Texture2D file " + Path.GetFileName(exportFullname) + " already exists"); + if (ExportFileExists(exportFullname, "Texture2D")) return false; - } - Directory.CreateDirectory(Path.GetDirectoryName(exportFullname)); - StatusStripUpdate("Exporting Texture2D: " + Path.GetFileName(exportFullname)); var m_Texture2D = new Texture2D(asset, true); if (oldextension == ".dds") { byte[] imageBuffer = Texture2DToDDS(m_Texture2D); - if ((bool)Properties.Settings.Default["convertTexture"]) + if (convert) { var bitmap = DDSToBMP(imageBuffer); if (flip) @@ -3166,7 +3162,7 @@ namespace Unity_Studio else if (oldextension == ".pvr") { var pvrdata = Texture2DToPVR(m_Texture2D); - if ((bool)Properties.Settings.Default["convertTexture"]) + if (convert) { var bitmap = new Bitmap(m_Texture2D.m_Width, m_Texture2D.m_Height); Rectangle rect = new Rectangle(0, 0, m_Texture2D.m_Width, m_Texture2D.m_Height); @@ -3186,7 +3182,7 @@ namespace Unity_Studio else if (oldextension == ".astc") { var astcdata = Texture2DToASTC(m_Texture2D); - if ((bool)Properties.Settings.Default["convertTexture"]) + if (convert) { string tempastcfilepath = Path.GetTempFileName(); string temptgafilepath = tempastcfilepath.Replace(".tmp", ".tga"); @@ -3228,13 +3224,8 @@ namespace Unity_Studio exportFileextension = ".wav"; } var exportFullname = exportFilename + exportFileextension; - if (File.Exists(exportFullname)) - { - StatusStripUpdate("AudioClip file " + Path.GetFileName(exportFullname) + " already exists"); + if (ExportFileExists(exportFullname, "AudioClip")) return false; - } - Directory.CreateDirectory(Path.GetDirectoryName(exportFullname)); - StatusStripUpdate("Exporting AudioClip: " + Path.GetFileName(exportFullname)); var m_AudioClip = new AudioClip(asset, true); if ((bool)Properties.Settings.Default["convertfsb"] && oldextension == ".fsb") { @@ -3301,7 +3292,7 @@ namespace Unity_Studio } else { - File.WriteAllBytes(exportFilename, m_AudioClip.m_AudioData); + File.WriteAllBytes(exportFullname, m_AudioClip.m_AudioData); } return true; } @@ -3329,7 +3320,6 @@ namespace Unity_Studio else { Directory.CreateDirectory(Path.GetDirectoryName(filename)); - StatusStripUpdate("Exporting " + assetType + ": " + Path.GetFileName(filename)); return false; }