예제 #1
0
        public void Init(SerializeAssetV15 serializeAsset)
        {
            AssetVersion = serializeAsset.header.Version;
            UnityVersion = serializeAsset.UnityVersion;
            ObjectInfos = new AssetObjectInfo[serializeAsset.numOfObjects];
            for (int i = 0; i < serializeAsset.numOfObjects; i++) {
                ObjectInfos[i] = new AssetObjectInfo();
                ObjectInfos[i].PathID = (ulong)serializeAsset.objectInfos[i].PathID;
                ObjectInfos[i].classID = serializeAsset.objectInfos[i].classID;
                ObjectInfos[i].typeID = serializeAsset.objectInfos[i].typeID;
                ObjectInfos[i].length = serializeAsset.objectInfos[i].length;
                ObjectInfos[i].data = serializeAsset.objectInfos[i].data;
            }

            ExternalFiles = new FileIdentifier[serializeAsset.numOfFileIdentifiers];
            for (int i = 0; i < serializeAsset.numOfFileIdentifiers; i++) {
                ExternalFiles[i] = new FileIdentifier();
                ExternalFiles[i].filePath = serializeAsset.fileIdentifiers[i].filePath;
            }
        }
예제 #2
0
        public void Init(SerializeAssetV15 serializeAsset)
        {
            AssetVersion = serializeAsset.header.Version;
            UnityVersion = serializeAsset.UnityVersion;
            ObjectInfos  = new AssetObjectInfo[serializeAsset.numOfObjects];
            for (int i = 0; i < serializeAsset.numOfObjects; i++)
            {
                ObjectInfos[i]         = new AssetObjectInfo();
                ObjectInfos[i].PathID  = (ulong)serializeAsset.objectInfos[i].PathID;
                ObjectInfos[i].classID = serializeAsset.objectInfos[i].classID;
                ObjectInfos[i].typeID  = serializeAsset.objectInfos[i].typeID;
                ObjectInfos[i].length  = serializeAsset.objectInfos[i].length;
                ObjectInfos[i].data    = serializeAsset.objectInfos[i].data;
            }

            ExternalFiles = new FileIdentifier[serializeAsset.numOfFileIdentifiers];
            for (int i = 0; i < serializeAsset.numOfFileIdentifiers; i++)
            {
                ExternalFiles[i]          = new FileIdentifier();
                ExternalFiles[i].filePath = serializeAsset.fileIdentifiers[i].filePath;
            }
        }
예제 #3
0
        static public TypeTreeDataBase GenerateTypeTreeDataBase(SerializeAssetV15 asset)
        {
            TypeTreeDataBase         DB            = new TypeTreeDataBase();
            Dictionary <int, string> typeNameTable = new Dictionary <int, string>();
            //一个共享的类型字符串表
            string defaultTypeStr = Properties.Resources.ResourceManager.GetString("TypeStringTableV15");
            var    typeStrArray   = defaultTypeStr.Split('\n');
            int    startOffset    = 1 << 31;

            for (int i = 0; i < typeStrArray.Length; i++)
            {
                typeNameTable[startOffset] = typeStrArray[i].Substring(0, typeStrArray[i].Length - 1);
                startOffset += typeStrArray[i].Length;
            }

            foreach (var baseClass in asset.classes)
            {
                if (baseClass.stringTable == null)
                {
                    continue;
                }
                Dictionary <int, string> onwerStrTable = new Dictionary <int, string>();
                MemoryStream             ms            = new MemoryStream(baseClass.stringTable);
                DataReader data     = new DataReader(ms);
                TypeTree   rootType = new TypeTree();
                TypeTree   nodePrev = null;

                Dictionary <TypeTree, int> typeLevelDic = new Dictionary <TypeTree, int>();
                foreach (var field in baseClass.types)
                {
                    string name = "";
                    string type = "";
                    if (field.nameOffset < 0)
                    {
                        if (typeNameTable.ContainsKey(field.nameOffset))
                        {
                            name = typeNameTable[field.nameOffset];
                        }
                    }
                    else
                    {
                        data.position = field.nameOffset;
                        name          = data.ReadStringNull();
                    }

                    if (field.typeOffset < 0)
                    {
                        if (typeNameTable.ContainsKey(field.typeOffset))
                        {
                            type = typeNameTable[field.typeOffset];
                        }
                    }
                    else
                    {
                        data.position = field.typeOffset;
                        type          = data.ReadStringNull();
                    }

                    if (nodePrev == null)
                    {
                        rootType.name          = name;
                        rootType.type          = type;
                        rootType.metaFlag      = field.metaFlag;
                        nodePrev               = rootType;
                        typeLevelDic[nodePrev] = field.treeLevel;
                        continue;
                    }
                    TypeTree nodeCurr = new TypeTree();
                    nodeCurr.name          = name;
                    nodeCurr.type          = type;
                    nodeCurr.metaFlag      = field.metaFlag;
                    typeLevelDic[nodeCurr] = field.treeLevel;
                    int levels = typeLevelDic[nodePrev] - field.treeLevel;
                    if (levels >= 0)
                    {
                        for (int i = 0; i < levels; i++)
                        {
                            nodePrev = nodePrev.parent;
                        }
                        nodePrev.parent.AddChild(nodeCurr);
                    }
                    else
                    {
                        nodePrev.AddChild(nodeCurr);
                    }
                    nodePrev = nodeCurr;
                }
                DB.Put(15, baseClass.ClassID, rootType);
                Console.Write(rootType);
                data.Close();
                ms.Close();
            }
            return(DB);
        }
        static public TypeTreeDataBase GenerateTypeTreeDataBase(SerializeAssetV15 asset)
        {

            TypeTreeDataBase DB = new TypeTreeDataBase();
            Dictionary<int, string> typeNameTable = new Dictionary<int, string>();
            //一个共享的类型字符串表
            string defaultTypeStr = Properties.Resources.ResourceManager.GetString("TypeStringTableV15");
            var typeStrArray = defaultTypeStr.Split('\n');
            int startOffset = 1 << 31;
            for (int i = 0; i < typeStrArray.Length; i++) {
                typeNameTable[startOffset] = typeStrArray[i].Substring(0, typeStrArray[i].Length-1);
                startOffset += typeStrArray[i].Length;
            }

            foreach (var baseClass in asset.classes) {
                if (baseClass.stringTable == null) continue;
                Dictionary<int, string> onwerStrTable = new Dictionary<int, string>();
                MemoryStream ms = new MemoryStream(baseClass.stringTable);
                DataReader data = new DataReader(ms);
                TypeTree rootType = new TypeTree();
                TypeTree nodePrev = null;
                
                Dictionary<TypeTree, int> typeLevelDic = new Dictionary<TypeTree, int>();
                foreach (var field in baseClass.types) {
                    string name = "";
                    string type = "";
                    if (field.nameOffset < 0) {
                        if (typeNameTable.ContainsKey(field.nameOffset)) {
                            name = typeNameTable[field.nameOffset];
                        }
                    } else {
                        data.position = field.nameOffset;
                        name = data.ReadStringNull();
                    }

                    if (field.typeOffset < 0) {
                        if (typeNameTable.ContainsKey(field.typeOffset)) {
                            type = typeNameTable[field.typeOffset];
                        }
                    } else {
                        data.position = field.typeOffset;
                        type = data.ReadStringNull();
                    }

                    if (nodePrev == null) {
                        rootType.name = name;
                        rootType.type = type;
                        rootType.metaFlag = field.metaFlag;
                        nodePrev = rootType;
                        typeLevelDic[nodePrev] = field.treeLevel;
                        continue;
                    }
                    TypeTree nodeCurr = new TypeTree();
                    nodeCurr.name = name;
                    nodeCurr.type = type;
                    nodeCurr.metaFlag = field.metaFlag;
                    typeLevelDic[nodeCurr] = field.treeLevel;
                    int levels = typeLevelDic[nodePrev] - field.treeLevel;
                    if (levels >= 0) {
                        for (int i = 0; i < levels; i++) {
                            nodePrev = nodePrev.parent;
                        }
                        nodePrev.parent.AddChild(nodeCurr);
                    } else {
                        nodePrev.AddChild(nodeCurr);
                    }
                    nodePrev = nodeCurr;
                }
                DB.Put(15, baseClass.ClassID, rootType);
                Console.Write(rootType);
                data.Close();
                ms.Close();
            }
            return DB;
        }