mirror of
https://github.com/aelurum/AssetStudio.git
synced 2025-07-19 11:34:16 -04:00
Improve file import
fixed bug
This commit is contained in:
@ -15,7 +15,7 @@ namespace Unity_Studio
|
||||
public VideoClip(AssetPreloadData preloadData, bool readSwitch)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var a_Stream = preloadData.sourceFile.a_Stream;
|
||||
var a_Stream = preloadData.sourceFile.assetsFileReader;
|
||||
a_Stream.Position = preloadData.Offset;
|
||||
|
||||
m_Name = a_Stream.ReadAlignedString(a_Stream.ReadInt32());
|
||||
@ -47,38 +47,49 @@ namespace Unity_Studio
|
||||
}
|
||||
//StreamedResource m_ExternalResources
|
||||
var m_Source = a_Stream.ReadAlignedString(a_Stream.ReadInt32());
|
||||
if (m_Source != "")
|
||||
m_Source = Path.Combine(Path.GetDirectoryName(sourceFile.filePath), m_Source.Replace("archive:/", ""));
|
||||
var m_Offset = a_Stream.ReadUInt64();
|
||||
var m_Size = a_Stream.ReadUInt64();
|
||||
var m_HasSplitAlpha = a_Stream.ReadBoolean();
|
||||
|
||||
if (readSwitch)
|
||||
{
|
||||
if (string.IsNullOrEmpty(m_Source))
|
||||
if (!string.IsNullOrEmpty(m_Source))
|
||||
{
|
||||
if (m_Size > 0)
|
||||
m_VideoData = 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))))
|
||||
{
|
||||
using (var reader = new BinaryReader(File.OpenRead(m_Source)))
|
||||
var resourceFileName = Path.GetFileName(m_Source);
|
||||
var resourceFilePath = Path.GetDirectoryName(sourceFile.filePath) + "\\" + resourceFileName;
|
||||
if (!File.Exists(resourceFilePath))
|
||||
{
|
||||
reader.BaseStream.Position = (long)m_Offset;
|
||||
m_VideoData = reader.ReadBytes((int)m_Size);
|
||||
var findFiles = Directory.GetFiles(Path.GetDirectoryName(sourceFile.filePath), resourceFileName, SearchOption.AllDirectories);
|
||||
if (findFiles.Length > 0)
|
||||
{
|
||||
resourceFilePath = findFiles[0];
|
||||
}
|
||||
}
|
||||
if (File.Exists(resourceFilePath))
|
||||
{
|
||||
using (var reader = new BinaryReader(File.OpenRead(resourceFilePath)))
|
||||
{
|
||||
reader.BaseStream.Position = (long)m_Offset;
|
||||
m_VideoData = reader.ReadBytes((int)m_Size);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (UnityStudio.resourceFileReaders.TryGetValue(resourceFileName.ToUpper(), out var reader))
|
||||
{
|
||||
reader.Position = (long)m_Offset;
|
||||
m_VideoData = reader.ReadBytes((int)m_Size);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show($"can't find the resource file {resourceFileName}");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (UnityStudio.assetsfileandstream.TryGetValue(Path.GetFileName(m_Source), out var reader))
|
||||
{
|
||||
reader.Position = (long)m_Offset;
|
||||
m_VideoData = reader.ReadBytes((int)m_Size);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show($"can't find the resource file {Path.GetFileName(m_Source)}");
|
||||
}
|
||||
if (m_Size > 0)
|
||||
m_VideoData = a_Stream.ReadBytes((int)m_Size);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
Reference in New Issue
Block a user