Beispiel #1
0
 private bool ShouldForceLoadObject(ObjectRecord record)
 {
     if (Types[record.TypeIndex].ClassID == AssetsConstants.ClassID.MonoScriptType)
     {
         return(true);
     }
     return(false);
 }
Beispiel #2
0
        //internal static IObjectInfo<AssetsObject> Parse(AssetsFile file, AssetsReader reader)
        //{
        //    var objectID = reader.ReadInt64();
        //    var dataOffset = reader.ReadInt32();
        //    var dataSize = reader.ReadInt32();
        //    var typeIndex = reader.ReadInt32();
        //    var obji = FromTypeIndex(file, typeIndex, null);
        //    obji.ObjectID = objectID;
        //    obji.DataOffset = dataOffset;
        //    obji.DataSize = dataSize;
        //    return obji;
        //}

        internal static IObjectInfo <AssetsObject> Parse(AssetsFile file, ObjectRecord record)
        {
            var obji = FromTypeIndex(file, record.TypeIndex, null);

            obji.ObjectID   = record.ObjectID;
            obji.DataOffset = record.DataOffset;
            obji.DataSize   = record.DataSize;
            return(obji);
        }
Beispiel #3
0
        private int PreloadObjectOrder(ObjectRecord record)
        {
            switch (Types[record.TypeIndex].ClassID)
            {
            case AssetsConstants.ClassID.MonoScriptType:
                return(0);

            default:
                return(10000);
            }
        }
Beispiel #4
0
        public void Parse(AssetsReader reader)
        {
            Version      = reader.ReadCStr();
            Platform     = reader.ReadInt32();
            HasTypeTrees = reader.ReadBoolean();
            int numTypes = reader.ReadInt32();

            for (int i = 0; i < numTypes; i++)
            {
                Types.Add(new AssetsType(reader, HasTypeTrees));
            }

            List <ObjectRecord> records = new List <ObjectRecord>();
            int numObj = reader.ReadInt32();

            for (int i = 0; i < numObj; i++)
            {
                reader.AlignTo(4);
                var obj = new ObjectRecord(reader);
                records.Add(obj);
            }

            int numAdds = reader.ReadInt32();

            for (int i = 0; i < numAdds; i++)
            {
                reader.AlignTo(4);
                Adds.Add(new RawPtr(reader));
            }
            int numExt = reader.ReadInt32();

            for (int i = 0; i < numExt; i++)
            {
                ExternalFiles.Add(new ExternalFile(reader));
            }
            reader.ReadCStr();

            //load the object infos in order based on their type
            foreach (var record in records.OrderBy(x => PreloadObjectOrder(x)).ThenBy(x => x.ObjectID))
            {
                var obj = ObjectInfo <AssetsObject> .Parse(ParentFile, record);

                ObjectInfos.Add(obj);
                if (ShouldForceLoadObject(record))
                {
                    var o = obj.Object;
                }
            }
        }