예제 #1
0
        static void LoadAssetFile(Stream s, out List <string> materials, out List <string> gameObjects)
        {
            var es         = new EndianStream(s, EndianType.BigEndian);
            var metaSize   = es.ReadUInt32();
            var fileSize   = es.ReadUInt32();
            var format     = es.ReadInt32();
            var dataOffset = es.ReadUInt32();

            if (format >= 9)
            {
                var endianness = es.ReadUInt32();
                if (endianness == 0)
                {
                    es.endian = EndianType.LittleEndian;
                }
            }

            var types = new TypeMeta();

            types.Load(es, format);

            var longObjIds = format >= 14 || (format >= 7 && es.ReadInt32() != 0);

            var numObjs = es.ReadUInt32();
            var objs    = new AssetObject[numObjs];

            for (uint i = 0; i < numObjs; i++)
            {
                if (format >= 14)
                {
                    es.AlignStream(4);
                }
                objs[i] = LoadObject(es, format, types);
            }
            materials   = new List <string>();
            gameObjects = new List <string>();
            foreach (var obj in objs)
            {
                types.TypeTrees.TryGetValue(obj.ClassId, out TreeNode type);
                es.Position = dataOffset + obj.DataOfs;
                if (obj.ClassId == 21)
                {
                    es.Position = dataOffset + obj.DataOfs;
                    materials.Add(es.ReadAlignedString(es.ReadInt32()));
                }
                if (obj.ClassId == 1)
                {
                    var v = (Dictionary <string, object>)ReadValue(es, type);
                    gameObjects.Add((string)v["m_Name"]);
                }

                /*
                 * if (obj.ClassId == 1 || obj.ClassId == 21) {
                 *  var v = (Dictionary<string, object>)ReadValue(es, type);
                 *  Debug.WriteLine(type.type + " " + v["m_Name"]);
                 * }
                 */
                /*
                 * if (type.children.Count != 0 && type.children[0].type == "string") {
                 *  es.Position = dataOffset + obj.DataOfs;
                 *  Debug.WriteLine(es.ReadAlignedString(es.ReadInt32()));
                 * }
                 */
            }
            //Debug.WriteLine(type);
        }