//[MenuItem("Assets/InsertAssetLibary")]
    static void ExportResource()
    {
        LibaryAssetSetting _assetSetting = Resources.Load <LibaryAssetSetting>("AssetLibarySetting");

        if (_assetSetting == null)
        {
            return;
        }
        string             path         = AssetDatabase.GetAssetPath(_assetSetting);
        LibaryAssetSetting assetSetting = AssetDatabase.LoadAssetAtPath <LibaryAssetSetting>(path);

        if (assetSetting == null)
        {
            return;
        }
        // 选择的要保存的对象
        Object[] selection = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);
        foreach (Object item in selection)
        {
            if (item == null || item.GetType() == typeof(DefaultAsset))
            {
                continue;
            }
            if (ResLibaryConfig.ExistType.ContainsValue(item.GetType().Name))
            {
                if (item.GetType().Name == ResLibaryConfig.ExistType[LibaryTypeEnum.LibaryType_Texture2D])
                {
                    string          tex2dpath       = AssetDatabase.GetAssetPath(item);
                    TextureImporter textureImporter = TextureImporter.GetAtPath(tex2dpath) as TextureImporter;
                    //SpriteMetaData[] sprs = textureImporter.spritesheet;
                    if (textureImporter.textureType == TextureImporterType.Sprite)
                    {
                        Object[] sprs = AssetDatabase.LoadAllAssetsAtPath(tex2dpath);
                        for (int i = 0; i < sprs.Length; i++)
                        {
                            //Sprite spr = AssetDatabase.LoadAssetAtPath<Sprite>(textPath + "/"+ sprs[i].name);
                            Object spr = sprs[i];
                            if (spr != null && spr.GetType().Name == ResLibaryConfig.ExistType[LibaryTypeEnum.LibaryType_Sprite])
                            {
                                assetSetting.AddResToLibary((Sprite)spr);
                            }
                        }
                        if (textureImporter.spriteImportMode != SpriteImportMode.Multiple)
                        {
                            assetSetting.AddResToLibary(item);
                        }
                    }
                }
                else
                {
                    assetSetting.AddResToLibary(item);
                }
            }
        }
        EditorUtility.SetDirty(assetSetting);
        AssetDatabase.ImportAsset(path);

        AssetDatabase.SaveAssets();
        AssetDatabase.Refresh();
    }
    private void UpdateAsset()
    {
        string path = AssetDatabase.GetAssetPath(resourseSetting);
        Dictionary <string, List <string> > msgDict = resourseSetting.GetAssetDict();
        //List<string> listRes = new List<string>(assetDict.Keys);
        List <string> ret = new List <string>();

        foreach (var item in assetDict)
        {
            if (item.Value)
            {
                string url = Application.dataPath + item.Key;//Path.Combine(Application.dataPath, item.Key);
                ret.Add(url);
                List <string> list = ResLibaryTool.GetAllSubDirs(url);
                if (list != null)
                {
                    ret.AddRange(list);
                }
            }
        }

        Debug.Log("ret:" + ret.Count);
        string dataPath = Application.dataPath.Replace("//", "/");

        dataPath = dataPath.Replace("\\", "/");
        dataPath = dataPath.Replace("\\\\", "/");
        for (int i = 0; i < ret.Count; i++)
        {
            string[] files = System.IO.Directory.GetFiles(ret[i]);
            for (int j = 0; j < files.Length; j++)
            {
                string file = files[j];

                string extension = Path.GetExtension(file);
                if (!ResLibaryConfig.ResourceExts.Contains(extension))
                {
                    continue;
                }

                file = file.Replace("//", "/");
                file = file.Replace("\\", "/");
                file = file.Replace("\\\\", "/");
                file = file.Replace(dataPath, "Assets");
                UnityEngine.Object obj = AssetDatabase.LoadMainAssetAtPath(file);
                if (obj == null)
                {
                    continue;
                }
                if (!ResLibaryConfig.ExistType.ContainsValue(obj.GetType().Name))
                {
                    continue;
                }
                if (obj.GetType().Name == ResLibaryConfig.ExistType[LibaryTypeEnum.LibaryType_Texture2D])
                {
                    string          resfile         = AssetDatabase.GetAssetPath(obj);
                    TextureImporter textureImporter = TextureImporter.GetAtPath(resfile) as TextureImporter;
                    if (textureImporter == null)
                    {
                        continue;
                    }
                    if (textureImporter.textureType == TextureImporterType.Sprite)
                    {
                        List <string> sDict = null;
                        msgDict.TryGetValue(ResLibaryConfig.ExistType[LibaryTypeEnum.LibaryType_Sprite], out sDict);
                        UnityEngine.Object[] sprs = AssetDatabase.LoadAllAssetsAtPath(resfile);
                        for (int k = 0; k < sprs.Length; k++)
                        {
                            if (sprs[k].GetType().Name == ResLibaryConfig.ExistType[LibaryTypeEnum.LibaryType_Sprite])
                            {
                                if (sDict != null && sDict.Contains(sprs[k].name))
                                {
                                    continue;
                                }
                                resourseSetting.AddResToLibary(sprs[k]);
                            }
                            else
                            {
                                List <string> sDictT = null;
                                msgDict.TryGetValue(ResLibaryConfig.ExistType[LibaryTypeEnum.LibaryType_Texture2D], out sDictT);
                                if (sDictT != null && sDictT.Contains(sprs[k].name))
                                {
                                    continue;
                                }
                                resourseSetting.AddResToLibary(sprs[k]);
                            }
                        }
                    }
                    else
                    {
                        List <string> sDict = null;
                        msgDict.TryGetValue(ResLibaryConfig.ExistType[LibaryTypeEnum.LibaryType_Texture2D], out sDict);
                        if (sDict != null && sDict.Contains(obj.name))
                        {
                            continue;
                        }
                        resourseSetting.AddResToLibary(obj);
                    }
                }
                else
                {
                    List <string> sDict = null;
                    msgDict.TryGetValue(obj.GetType().Name, out sDict);
                    if (sDict != null && sDict.Contains(obj.name))
                    {
                        continue;
                    }
                    resourseSetting.AddResToLibary(obj);
                }
            }
        }
        AssetDatabase.ImportAsset(path);
        AssetDatabase.SaveAssets();
        AssetDatabase.Refresh();
    }