mirror of
https://github.com/aelurum/AssetStudio.git
synced 2025-05-27 22:00:23 -04:00
Fixed some bugs
This commit is contained in:
parent
16ed347a30
commit
332e4cc6e2
@ -95,7 +95,7 @@ namespace Unity_Studio
|
|||||||
private static extern bool DecompressCRN(byte[] pSrc_file_data, int src_file_size, out IntPtr dxtdata, out int dxtsize);
|
private static extern bool DecompressCRN(byte[] pSrc_file_data, int src_file_size, out IntPtr dxtdata, out int dxtsize);
|
||||||
|
|
||||||
[DllImport("texgenpack.dll", CallingConvention = CallingConvention.Cdecl)]
|
[DllImport("texgenpack.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
private static extern bool texgenpackdecode(int texturetype, byte[] texturedata, int width, int height, IntPtr bmp, bool fixAlpha);
|
private static extern void texgenpackdecode(int texturetype, byte[] texturedata, int width, int height, IntPtr bmp, bool fixAlpha);
|
||||||
|
|
||||||
public Texture2D(AssetPreloadData preloadData, bool readSwitch)
|
public Texture2D(AssetPreloadData preloadData, bool readSwitch)
|
||||||
{
|
{
|
||||||
|
@ -273,14 +273,13 @@ namespace Unity_Studio
|
|||||||
private void readBase5()
|
private void readBase5()
|
||||||
{
|
{
|
||||||
int classID = a_Stream.ReadInt32();
|
int classID = a_Stream.ReadInt32();
|
||||||
if (fileGen > 15)
|
if (fileGen > 15)//5.5.0 and up
|
||||||
{
|
{
|
||||||
a_Stream.ReadByte();
|
a_Stream.ReadByte();
|
||||||
int type1;
|
int type1;
|
||||||
if ((type1 = a_Stream.ReadInt16()) >= 0)
|
if ((type1 = a_Stream.ReadInt16()) >= 0)
|
||||||
{
|
{
|
||||||
type1 = -1 - type1;
|
type1 = -1 - type1;
|
||||||
a_Stream.Position += 16;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -288,13 +287,21 @@ namespace Unity_Studio
|
|||||||
}
|
}
|
||||||
classIDs.Add(new[] { type1, classID });
|
classIDs.Add(new[] { type1, classID });
|
||||||
classID = type1;
|
classID = type1;
|
||||||
//TODO 某些文件出现type1=-1时还需要跳过16字节的情况
|
/*TODO 替换?
|
||||||
|
if(classID == 114)
|
||||||
|
{
|
||||||
|
a_Stream.Position += 16;
|
||||||
|
}*/
|
||||||
var temp = a_Stream.ReadInt32();
|
var temp = a_Stream.ReadInt32();
|
||||||
if (temp == 0)
|
if (temp == 0)
|
||||||
{
|
{
|
||||||
a_Stream.Position += 16;
|
a_Stream.Position += 16;
|
||||||
}
|
}
|
||||||
a_Stream.Position -= 4;
|
a_Stream.Position -= 4;
|
||||||
|
if (type1 < 0)
|
||||||
|
{
|
||||||
|
a_Stream.Position += 16;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (classID < 0)
|
else if (classID < 0)
|
||||||
{
|
{
|
||||||
|
@ -69,9 +69,9 @@ namespace Unity_Studio
|
|||||||
{
|
{
|
||||||
int bundleSize = b_Stream.ReadInt32();
|
int bundleSize = b_Stream.ReadInt32();
|
||||||
}
|
}
|
||||||
else
|
else if (format == 6)
|
||||||
{
|
{
|
||||||
long bundleSize = b_Stream.ReadInt64();
|
ReadFormat6(b_Stream, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
short dummy2 = b_Stream.ReadInt16();
|
short dummy2 = b_Stream.ReadInt16();
|
||||||
@ -116,11 +116,41 @@ namespace Unity_Studio
|
|||||||
versionPlayer = b_Stream.ReadStringToNull();
|
versionPlayer = b_Stream.ReadStringToNull();
|
||||||
versionEngine = b_Stream.ReadStringToNull();
|
versionEngine = b_Stream.ReadStringToNull();
|
||||||
if (format == 6)
|
if (format == 6)
|
||||||
|
{
|
||||||
|
ReadFormat6(b_Stream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getFiles(EndianStream f_Stream, int offset)
|
||||||
|
{
|
||||||
|
int fileCount = f_Stream.ReadInt32();
|
||||||
|
for (int i = 0; i < fileCount; i++)
|
||||||
|
{
|
||||||
|
MemoryAssetsFile memFile = new MemoryAssetsFile();
|
||||||
|
memFile.fileName = f_Stream.ReadStringToNull();
|
||||||
|
int fileOffset = f_Stream.ReadInt32();
|
||||||
|
fileOffset += offset;
|
||||||
|
int fileSize = f_Stream.ReadInt32();
|
||||||
|
long nextFile = f_Stream.Position;
|
||||||
|
f_Stream.Position = fileOffset;
|
||||||
|
|
||||||
|
byte[] buffer = new byte[fileSize];
|
||||||
|
f_Stream.Read(buffer, 0, fileSize);
|
||||||
|
memFile.memStream = new MemoryStream(buffer);
|
||||||
|
MemoryAssetsFileList.Add(memFile);
|
||||||
|
f_Stream.Position = nextFile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ReadFormat6(EndianStream b_Stream, bool padding = false)
|
||||||
{
|
{
|
||||||
var bundleSize = b_Stream.ReadInt64();
|
var bundleSize = b_Stream.ReadInt64();
|
||||||
int compressedSize = b_Stream.ReadInt32();
|
int compressedSize = b_Stream.ReadInt32();
|
||||||
int uncompressedSize = b_Stream.ReadInt32();
|
int uncompressedSize = b_Stream.ReadInt32();
|
||||||
int flag = b_Stream.ReadInt32();
|
int flag = b_Stream.ReadInt32();
|
||||||
|
if (padding)
|
||||||
|
b_Stream.ReadByte();
|
||||||
byte[] blocksInfoBytes;
|
byte[] blocksInfoBytes;
|
||||||
if ((flag & 0x80) != 0)//at end of file
|
if ((flag & 0x80) != 0)//at end of file
|
||||||
{
|
{
|
||||||
@ -232,26 +262,3 @@ namespace Unity_Studio
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getFiles(EndianStream f_Stream, int offset)
|
|
||||||
{
|
|
||||||
int fileCount = f_Stream.ReadInt32();
|
|
||||||
for (int i = 0; i < fileCount; i++)
|
|
||||||
{
|
|
||||||
MemoryAssetsFile memFile = new MemoryAssetsFile();
|
|
||||||
memFile.fileName = f_Stream.ReadStringToNull();
|
|
||||||
int fileOffset = f_Stream.ReadInt32();
|
|
||||||
fileOffset += offset;
|
|
||||||
int fileSize = f_Stream.ReadInt32();
|
|
||||||
long nextFile = f_Stream.Position;
|
|
||||||
f_Stream.Position = fileOffset;
|
|
||||||
|
|
||||||
byte[] buffer = new byte[fileSize];
|
|
||||||
f_Stream.Read(buffer, 0, fileSize);
|
|
||||||
memFile.memStream = new MemoryStream(buffer);
|
|
||||||
MemoryAssetsFileList.Add(memFile);
|
|
||||||
f_Stream.Position = nextFile;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -228,7 +228,7 @@ namespace Unity_Studio
|
|||||||
StatusStripUpdate("Extracting " + Path.GetFileName(memFile.fileName));
|
StatusStripUpdate("Extracting " + Path.GetFileName(memFile.fileName));
|
||||||
extractedCount += 1;
|
extractedCount += 1;
|
||||||
|
|
||||||
using (FileStream file = new FileStream(filePath, FileMode.Create, System.IO.FileAccess.Write))
|
using (FileStream file = new FileStream(filePath, FileMode.Create, FileAccess.Write))
|
||||||
{
|
{
|
||||||
memFile.memStream.WriteTo(file);
|
memFile.memStream.WriteTo(file);
|
||||||
memFile.memStream.Close();
|
memFile.memStream.Close();
|
||||||
@ -1612,7 +1612,7 @@ namespace Unity_Studio
|
|||||||
else if (ext == "JPEG")
|
else if (ext == "JPEG")
|
||||||
format = ImageFormat.Jpeg;
|
format = ImageFormat.Jpeg;
|
||||||
var exportFullName = exportPathName + asset.Text + "." + ext.ToLower();
|
var exportFullName = exportPathName + asset.Text + "." + ext.ToLower();
|
||||||
if (ExportFileExists(exportFullName, asset.TypeString))
|
if (ExportFileExists(exportFullName))
|
||||||
return false;
|
return false;
|
||||||
var bitmap = m_Texture2D.ConvertToBitmap(flip);
|
var bitmap = m_Texture2D.ConvertToBitmap(flip);
|
||||||
if (bitmap != null)
|
if (bitmap != null)
|
||||||
@ -1623,7 +1623,7 @@ namespace Unity_Studio
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
var exportFullName2 = exportPathName + asset.Text + asset.extension;
|
var exportFullName2 = exportPathName + asset.Text + asset.extension;
|
||||||
if (ExportFileExists(exportFullName2, asset.TypeString))
|
if (ExportFileExists(exportFullName2))
|
||||||
return false;
|
return false;
|
||||||
File.WriteAllBytes(exportFullName2, m_Texture2D.ConvertToContainer());
|
File.WriteAllBytes(exportFullName2, m_Texture2D.ConvertToContainer());
|
||||||
return true;
|
return true;
|
||||||
@ -1637,7 +1637,7 @@ namespace Unity_Studio
|
|||||||
exportFileextension = ".wav";
|
exportFileextension = ".wav";
|
||||||
}
|
}
|
||||||
var exportFullname = exportFilename + exportFileextension;
|
var exportFullname = exportFilename + exportFileextension;
|
||||||
if (ExportFileExists(exportFullname, "AudioClip"))
|
if (ExportFileExists(exportFullname))
|
||||||
return false;
|
return false;
|
||||||
var m_AudioClip = new AudioClip(asset, true);
|
var m_AudioClip = new AudioClip(asset, true);
|
||||||
if ((bool)Properties.Settings.Default["convertfsb"] && oldextension == ".fsb")
|
if ((bool)Properties.Settings.Default["convertfsb"] && oldextension == ".fsb")
|
||||||
@ -1733,7 +1733,7 @@ namespace Unity_Studio
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool ExportFileExists(string filename, string assetType)
|
public static bool ExportFileExists(string filename)
|
||||||
{
|
{
|
||||||
if (File.Exists(filename))
|
if (File.Exists(filename))
|
||||||
{
|
{
|
||||||
|
@ -1336,7 +1336,7 @@ namespace Unity_Studio
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 48:
|
case 48:
|
||||||
if (!ExportFileExists(exportpath + asset.Text + asset.extension, asset.TypeString))
|
if (!ExportFileExists(exportpath + asset.Text + asset.extension))
|
||||||
{
|
{
|
||||||
ExportShader(new Shader(asset, true), exportpath + asset.Text + ".txt");
|
ExportShader(new Shader(asset, true), exportpath + asset.Text + ".txt");
|
||||||
exportedCount++;
|
exportedCount++;
|
||||||
@ -1344,7 +1344,7 @@ namespace Unity_Studio
|
|||||||
break;
|
break;
|
||||||
case 49:
|
case 49:
|
||||||
TextAsset m_TextAsset = new TextAsset(asset, true);
|
TextAsset m_TextAsset = new TextAsset(asset, true);
|
||||||
if (!ExportFileExists(exportpath + asset.Text + asset.extension, asset.TypeString))
|
if (!ExportFileExists(exportpath + asset.Text + asset.extension))
|
||||||
{
|
{
|
||||||
ExportText(m_TextAsset, exportpath + asset.Text + asset.extension);
|
ExportText(m_TextAsset, exportpath + asset.Text + asset.extension);
|
||||||
exportedCount++;
|
exportedCount++;
|
||||||
@ -1352,7 +1352,7 @@ namespace Unity_Studio
|
|||||||
break;
|
break;
|
||||||
case 114:
|
case 114:
|
||||||
MonoBehaviour m_MonoBehaviour = new MonoBehaviour(asset, true);
|
MonoBehaviour m_MonoBehaviour = new MonoBehaviour(asset, true);
|
||||||
if (!ExportFileExists(exportpath + asset.Text + asset.extension, asset.TypeString))
|
if (!ExportFileExists(exportpath + asset.Text + asset.extension))
|
||||||
{
|
{
|
||||||
ExportMonoBehaviour(m_MonoBehaviour, exportpath + asset.Text + asset.extension);
|
ExportMonoBehaviour(m_MonoBehaviour, exportpath + asset.Text + asset.extension);
|
||||||
exportedCount++;
|
exportedCount++;
|
||||||
@ -1360,14 +1360,14 @@ namespace Unity_Studio
|
|||||||
break;
|
break;
|
||||||
case 128:
|
case 128:
|
||||||
unityFont m_Font = new unityFont(asset, true);
|
unityFont m_Font = new unityFont(asset, true);
|
||||||
if (!ExportFileExists(exportpath + asset.Text + asset.extension, asset.TypeString))
|
if (!ExportFileExists(exportpath + asset.Text + asset.extension))
|
||||||
{
|
{
|
||||||
ExportFont(m_Font, exportpath + asset.Text + asset.extension);
|
ExportFont(m_Font, exportpath + asset.Text + asset.extension);
|
||||||
exportedCount++;
|
exportedCount++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (!ExportFileExists(exportpath + asset.Text + asset.extension, asset.TypeString))
|
if (!ExportFileExists(exportpath + asset.Text + asset.extension))
|
||||||
{
|
{
|
||||||
ExportRawFile(asset, exportpath + asset.Text + asset.extension);
|
ExportRawFile(asset, exportpath + asset.Text + asset.extension);
|
||||||
exportedCount++;
|
exportedCount++;
|
||||||
|
Loading…
Reference in New Issue
Block a user