SkinnedMeshRenderer fix for Unity 5

sharedFiles properly linked
This commit is contained in:
RaduMCosma 2015-11-02 13:32:13 +02:00
parent 66fa804819
commit a928ffbf92
3 changed files with 30 additions and 22 deletions

View File

@ -334,10 +334,7 @@ namespace Unity_Studio
}
m_Name = a_Stream.ReadAlignedString(a_Stream.ReadInt32());
if (m_Name == "holotable_glow_mesh")
{
bool stop = true;
}
if (version[0] < 3 || (version[0] == 3 && version[1] < 5))
{
m_Use16BitIndices = a_Stream.ReadBoolean();

View File

@ -34,7 +34,7 @@ namespace Unity_Studio
if (sourceFile.version[0] < 5)
{
m_Enabled = a_Stream.ReadBoolean();
m_CastShadows = a_Stream.ReadByte();
m_CastShadows = a_Stream.ReadByte();//bool
m_ReceiveShadows = a_Stream.ReadBoolean();
m_LightmapIndex = a_Stream.ReadByte();
}
@ -66,7 +66,7 @@ namespace Unity_Studio
a_Stream.Position += m_SubsetIndices_size * 4;
PPtr m_StaticBatchRoot = sourceFile.ReadPPtr();
if ((version[0] == 3 && version[1] >= 5) || version[0] >= 4)
if (version[0] >= 4 || (version[0] == 3 && version[1] >= 5))
{
bool m_UseLightProbes = a_Stream.ReadBoolean();
a_Stream.Position += 3; //alignment
@ -75,10 +75,11 @@ namespace Unity_Studio
PPtr m_LightProbeAnchor = sourceFile.ReadPPtr();
}
if (version[0] >= 4 && version[1] >= 3)
if (version[0] >= 5 || (version[0] == 4 && version[1] >= 3))
{
if (version[1] >= 5) { int m_SortingLayer = a_Stream.ReadInt32(); }
else { int m_SortingLayer = a_Stream.ReadInt16(); }
if (version[0] == 4 && version[1] <= 3) { int m_SortingLayer = a_Stream.ReadInt16(); }
else { int m_SortingLayer = a_Stream.ReadInt32(); }
int m_SortingOrder = a_Stream.ReadInt16();
a_Stream.AlignStream(4);
}
@ -97,7 +98,7 @@ namespace Unity_Studio
m_Mesh = sourceFile.ReadPPtr();
int m_Bones_size = a_Stream.ReadInt32();
/*int m_Bones_size = a_Stream.ReadInt32();
for (int b = 0; b < m_Bones_size; b++)
{
PPtr aBone = sourceFile.ReadPPtr();
@ -118,7 +119,7 @@ namespace Unity_Studio
float[] m_Center = new float[] { a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle() };
float[] m_Extent = new float[] { a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle() };
bool m_DirtyAABB = a_Stream.ReadBoolean();
}
}*/
}
}
}

View File

@ -83,10 +83,11 @@ namespace Unity_Studio
progressBar1.Value = 0;
progressBar1.Maximum = unityFiles.Count;
foreach (var filename in openFileDialog1.FileNames)
//use a for loop because list size can change
for (int f = 0; f < unityFiles.Count; f++)
{
StatusStripUpdate("Loading " + Path.GetFileName(filename));
LoadAssetsFile(filename);
StatusStripUpdate("Loading " + Path.GetFileName(unityFiles[f]));
LoadAssetsFile(unityFiles[f]);
}
}
else
@ -240,9 +241,7 @@ namespace Unity_Studio
foreach (var sharedFile in assetsFile.sharedAssetsList)
{
string sharedFilePath = Path.GetDirectoryName(fileName) + "\\" + sharedFile.fileName;
//TODO add extra code to search for the shared file in case it doesn't exist in the main folder
//or if it exists or the path is incorrect
string sharedFileName = Path.GetFileName(sharedFile.fileName);
//var loadedSharedFile = assetsfileList.Find(aFile => aFile.filePath == sharedFilePath);
/*var loadedSharedFile = assetsfileList.Find(aFile => aFile.filePath.EndsWith(Path.GetFileName(sharedFile.fileName)));
@ -255,12 +254,23 @@ namespace Unity_Studio
}*/
//searching in unityFiles would preserve desired order, but...
var quedSharedFile = unityFiles.Find(uFile => uFile.EndsWith(Path.GetFileName(sharedFile.fileName)));
if (quedSharedFile == null && File.Exists(sharedFilePath))
var quedSharedFile = unityFiles.Find(uFile => String.Equals(Path.GetFileName(uFile), sharedFileName, StringComparison.OrdinalIgnoreCase));
if (quedSharedFile == null)
{
sharedFile.Index = unityFiles.Count;//this would get screwed if the file fails to load
unityFiles.Add(sharedFilePath);
progressBar1.Maximum++;
//if (!File.Exists(sharedFilePath)) { sharedFilePath = Path.GetDirectoryName(fileName) + "\\" + sharedFileName; }
if (!File.Exists(sharedFilePath))
{
var findFiles = Directory.GetFiles(Path.GetDirectoryName(fileName), sharedFileName, SearchOption.AllDirectories);
if (findFiles.Length > 0) { sharedFilePath = findFiles[0]; }
}
if (File.Exists(sharedFilePath))
{
//this would get screwed if the file somehow fails to load
sharedFile.Index = unityFiles.Count;
unityFiles.Add(sharedFilePath);
progressBar1.Maximum++;
}
}
else { sharedFile.Index = unityFiles.IndexOf(quedSharedFile); }
}