コード例 #1
0
 internal void Read(EndianReader reader)
 {
     if (RTTIClassHierarchyDescriptor.IsReadSignature(Header.Generation))
     {
         ReadAssets(reader);
     }
     else
     {
         Logger.Log(LogType.Warning, LogCategory.Import, $"Can't determine file version for generation {Header.Generation} for file '{Name}'");
         string[] versions = GetGenerationVersions(Header.Generation);
         for (int i = 0; i < versions.Length; i++)
         {
             string version = versions[i];
             Logger.Log(LogType.Debug, LogCategory.Import, $"Try parse {Name} as {version} version");
             Metadata.Hierarchy.Version.Parse(version);
             m_assets.Clear();
             try
             {
                 ReadAssets(reader);
                 UpdateFileVersion();
                 break;
             }
             catch
             {
                 Logger.Log(LogType.Debug, LogCategory.Import, "Faild");
                 if (i == versions.Length - 1)
                 {
                     throw;
                 }
             }
         }
     }
 }
コード例 #2
0
 private void UpdateFileVersion()
 {
     if (!RTTIClassHierarchyDescriptor.IsReadSignature(Header.Generation))
     {
         foreach (Object asset in FetchAssets())
         {
             if (asset.ClassID == ClassIDType.BuildSettings)
             {
                 BuildSettings settings = (BuildSettings)asset;
                 Metadata.Hierarchy.Version.Parse(settings.Version);
                 return;
             }
         }
     }
 }
コード例 #3
0
        private void Read(Stream stream, Action <string> dependencyCallback)
        {
            long startPosition = stream.Position;

            using (EndianReader reader = new EndianReader(stream, stream.Position, EndianType.BigEndian))
            {
                Header.Read(reader);
            }

            EndianType endianess = Header.SwapEndianess ? EndianType.BigEndian : EndianType.LittleEndian;

            using (EndianReader reader = new EndianReader(stream, stream.Position, endianess))
            {
                if (IsTableAtTheEnd(Header.Generation))
                {
                    reader.BaseStream.Position = startPosition + Header.FileSize - Header.MetadataSize;
                    reader.BaseStream.Position++;
                }

                using (SerializedFileReader fileReader = new SerializedFileReader(reader, Header.Generation))
                {
                    Metadata.Read(fileReader);
                }

#warning TEMP HACK
                Flags  = Platform == Platform.NoTarget ? TransferInstructionFlags.NoTransferInstructionFlags : Flags;
                Flags |= Header.SwapEndianess ? TransferInstructionFlags.SwapEndianess : TransferInstructionFlags.NoTransferInstructionFlags;

                foreach (FileIdentifier dependency in Dependencies)
                {
                    dependencyCallback?.Invoke(dependency.FilePath);
                }

                if (RTTIClassHierarchyDescriptor.IsReadSignature(Header.Generation))
                {
                    ReadAssets(reader, startPosition);
                }
                else
                {
                    Logger.Log(LogType.Warning, LogCategory.Import, $"Can't determine file version for generation {Header.Generation} for file '{Name}'");
                    string[] versions = GetGenerationVersions(Header.Generation);
                    for (int i = 0; i < versions.Length; i++)
                    {
                        string version = versions[i];
                        Logger.Log(LogType.Debug, LogCategory.Import, $"Try parse {Name} as {version} version");
                        Metadata.Hierarchy.Version.Parse(version);
                        m_assets.Clear();
                        try
                        {
                            ReadAssets(reader, startPosition);
                            break;
                        }
                        catch
                        {
                            Logger.Log(LogType.Debug, LogCategory.Import, "Faild");
                            if (i == versions.Length - 1)
                            {
                                throw;
                            }
                        }
                    }
                }
            }
        }