Exemplo n.º 1
0
        public static AssetBundleInfoList GeneratorAssetBundleInfo()
        {
            AssetBundleInfoList infoList = new AssetBundleInfoList();

            List <string> list = new List <string>();

            PathUtil.RecursiveFile(resourceRoot, list, exts);

            for (int i = 0; i < list.Count; i++)
            {
                string        path     = list[i];
                AssetImporter importer = AssetImporter.GetAtPath(path);

                if (string.IsNullOrEmpty(importer.assetBundleName))
                {
                    Debug.LogWarningFormat("MResource资源没有设置AssetBundleName  path={0}", path);
                    continue;
                }

                AssetBundleInfo item = new AssetBundleInfo();
                item.path            = path;
                item.assetBundleName = importer.assetBundleName;
                item.assetName       = PathUtil.ChangeExtension(Path.GetFileName(path), string.Empty);



                string ext = Path.GetExtension(path).ToLower();
                if (ext == ".prefab")
                {
                    item.objType = AssetManagerSetting.ObjType_GameObject;
                }
                else if (imageExts.IndexOf(ext) != -1)
                {
                    TextureImporter textureImporter = TextureImporter.GetAtPath(path) as TextureImporter;
                    if (textureImporter.textureType == TextureImporterType.Sprite)
                    {
                        item.objType = AssetManagerSetting.ObjType_Sprite;
                    }
                }


                infoList.Add(item);
            }

            EditorUtility.ClearProgressBar();
            infoList.Save(AssetManagerSetting.EditorGetAbsoluteStreamPath(AssetManagerSetting.AssetBundleListName));
            AssetDatabase.Refresh();

            return(infoList);
        }
Exemplo n.º 2
0
        public static AssetBundleInfoList Deserialize(string txt)
        {
            AssetBundleInfoList list = new AssetBundleInfoList();

            using (StringReader stringReader = new StringReader(txt))
            {
                while (stringReader.Peek() >= 0)
                {
                    string line = stringReader.ReadLine();
                    if (!string.IsNullOrEmpty(line))
                    {
                        string[]        seg  = line.Split(';');
                        AssetBundleInfo item = new AssetBundleInfo();
                        item.path            = seg[0];
                        item.assetBundleName = seg[1];
                        item.assetName       = seg[2];
                        item.objType         = seg[3];
                        list.Add(item);
                    }
                }
            }

            return(list);
        }