private void OnCheckIgnore()
    {
        _ignoreList.Clear();
        if (HitManager.GetAllManagers().Count <= 0)
        {
            return;
        }

        foreach (UISpriteData data in _targetAtlas.spriteList)
        {
            HitManager mgr = HitManager.GetManager(data.name);
            if (mgr != null && mgr.hitTotal > 0)
            {
                continue;
            }

            foreach (string suffix in _ignoreSuffixs)
            {
                if (data.name.EndsWith(suffix))
                {
                    string prefix = data.name.Replace(suffix, "");
                    foreach (HitManager manager in HitManager.GetAllManagers())
                    {
                        if (manager.hitTotal > 0 &&
                            manager.spriteName != data.name && manager.spriteName.StartsWith(prefix))
                        {
                            _ignoreList.Add(data.name);
                        }
                    }
                }
            }
        }
    }
    /// <summary>
    /// 检查全部
    /// </summary>
    private void OnCheckSameFile(List <string> validList = null)
    {
        InitSame();

        UpdateSizeHitDct(validList);

        foreach (List <string> list in _size2Filenames.Values)
        {
            if (list != null && list.Count > 1)
            {
                UpdateHashHitFiles(list, validList);
            }
        }
        HitManager.Clear();

        //初始化
        PrefabSpriteManager.InitAndCheck();
        foreach (List <string> list in _hash2Filenames.Values)
        {
            if (list == null || list.Count <= 1)
            {
                continue;
            }

            foreach (string filename in list)
            {
                string filePath = filename;
                if (!PrefabSpriteManager.pngName2Refs.ContainsKey(filePath))
                {
                    continue;
                }
                var        spriteDataList = PrefabSpriteManager.pngName2Refs[filePath];
                HitManager managr         = HitManager.GetManager(filePath);
                foreach (var spriteData in spriteDataList)
                {
                    managr.SetEditPrefab(spriteData.prefabName, spriteData.uiPath);
                    managr.AddHit(spriteData.spriteUIPath);
                }
            }
        }

        _sameCount = 0;
        foreach (List <string> list in _hash2Filenames.Values)
        {
            if (list != null && list.Count > 1)
            {
                _sameCount++;
            }
        }

        Debug.Log(string.Format("重复数为:{0}", _sameCount));

        _refCount = 0;
        foreach (var manager in HitManager.GetAllManagers())
        {
            _refCount += manager.hitTotal;
        }
        Debug.Log(string.Format("UI引用数为:{0}", _refCount));
    }
    /// <summary>
    /// 图集引用检测
    /// </summary>
    private void OnAtlasRefGUI()
    {
        //EditorGUILayout.Space();
        string curFolder = EditorGUILayout.TextField("prefab根目录:", _prefabFolder);
        var    curAtlas  = (UIAtlas)EditorGUILayout.ObjectField("UIAtlas:", _targetAtlas, typeof(UIAtlas), false);

        if (curAtlas == null || _targetAtlas != curAtlas || curFolder != _prefabFolder)
        {
            NGUIPrefabAtlasCheck.HitManager.Clear();
            _alreadyCheck = false;
        }

        _targetAtlas  = curAtlas;
        _prefabFolder = curFolder;

        if (GUILayout.Button("Check", "LargeButton", GUILayout.Height(50f)))
        {
            OnCheckAtlas();
            OnCheckIgnore();
            _alreadyCheck = true;
        }

        List <HitManager> hitList    = HitManager.GetAllManagers();
        List <HitManager> notHitList = new List <HitManager>();

        if (hitList.Count > 0)
        {
            GUILayout.BeginHorizontal();
            string after = EditorGUILayout.TextField("", _searchSprite, "SearchTextField");
            if (_searchSprite != after)
            {
                _searchSprite = after;
            }
            GUILayout.EndHorizontal();
            GUILayout.Space(5f);

            _resultScrollPos = EditorGUILayout.BeginScrollView(_resultScrollPos, GUILayout.MinHeight(300f));
            foreach (var manager in hitList)
            {
                if (_searchSprite != null && (!manager.spriteName.Contains(_searchSprite)))
                {
                    continue;
                }

                if (!_spriteFolderExpand.ContainsKey(manager.spriteName))
                {
                    _spriteFolderExpand.Add(manager.spriteName, false);
                }

                if (manager.hitTotal <= 0)
                {
                    GUI.color = Color.red;
                }
                string sFolder = string.Format("{0} Count:{1}", manager.spriteName, manager.hitTotal);
                _spriteFolderExpand[manager.spriteName] = EditorGUILayout.Foldout(_spriteFolderExpand[manager.spriteName], sFolder);
                GUI.color = Color.white;

                if (manager.hitTotal <= 0)
                {
                    notHitList.Add(manager);
                    continue;
                }

                if (_spriteFolderExpand[manager.spriteName])
                {
                    for (int i = 0; i < manager.hitDataList.Count; i++)
                    {
                        HitData data = manager.hitDataList[i];
                        GUILayout.Space(-1f);
                        GUI.backgroundColor = data == _selectHit ? Color.white : new Color(0.8f, 0.8f, 0.8f);
                        GUILayout.BeginHorizontal("AS TextArea", GUILayout.MinHeight(20f));
                        GUI.backgroundColor = Color.white;
                        GUILayout.Space(15f);
                        GUILayout.Label(i.ToString(), GUILayout.Width(40f));
                        string sText = string.Format("{0}.prefab count:{1}", data.prefabName, data.hitCount);
                        if (GUILayout.Button(sText, "OL TextField", GUILayout.Height(20f)))
                        {
                            _selectHit        = data;
                            _selectSpriteName = manager.spriteName;
                        }
                        GUILayout.EndHorizontal();
                    }
                }
            }
            EditorGUILayout.EndScrollView();
            string sResult = string.Format("Search Result: {0}/{1}(未引用/全部)", notHitList.Count, hitList.Count);
            if (EditorHelper.DrawHeader(sResult, "result", false, false))
            {
                _notRefScrollPos = EditorGUILayout.BeginScrollView(_notRefScrollPos, GUILayout.MinHeight(180f));
                foreach (var data in notHitList)
                {
                    GUI.backgroundColor = _ignoreList.Contains(data.spriteName) ? Color.red : Color.white;
                    GUILayout.BeginHorizontal("AS TextArea", GUILayout.MinHeight(20f));
                    GUI.backgroundColor = Color.white;
                    GUILayout.Space(15f);
                    GUILayout.Label(data.spriteName);
                    if (!_ignoreList.Contains(data.spriteName))
                    {
                        if (GUILayout.Button("忽略", GUILayout.Width(60f)))
                        {
                            if (!_ignoreList.Contains(data.spriteName))
                            {
                                _ignoreList.Add(data.spriteName);
                            }
                        }
                    }
                    else
                    {
                        GUI.backgroundColor = Color.green;
                        if (GUILayout.Button("取消忽略", GUILayout.Width(85f)))
                        {
                            if (_ignoreList.Contains(data.spriteName))
                            {
                                _ignoreList.Remove(data.spriteName);
                            }
                        }
                    }
                    GUI.backgroundColor = Color.white;
                    GUILayout.EndHorizontal();
                }
                EditorGUILayout.EndScrollView();
            }


            if (GUILayout.Button("一键移除未被引用的sprite", "LargeButton", GUILayout.Height(50f)))
            {
                if (notHitList.Count > 0)
                {
                    if (EditorUtility.DisplayDialog("确认", "将会删除imgs文件夹下相应的png,确认后请等待数秒", "继续", "取消"))
                    {
                        string atlasPath  = AssetDatabase.GetAssetPath(_targetAtlas);
                        string folderPath = atlasPath.Replace("/" + _targetAtlas.name + ".prefab", "");

                        int total  = 0;
                        int remove = 0;
                        foreach (var manager in notHitList)
                        {
                            ++total;
                            if (_ignoreList.Contains(manager.spriteName))
                            {
                                continue;
                            }
                            string src = folderPath + "/imgs/" + manager.spriteName + ".png";
                            if (AssetDatabase.MoveAssetToTrash(src))
                            {
                                ++remove;
                            }
                        }
                        EditorUtility.DisplayDialog("移除完毕", string.Format("成功移除{0}/{1}。请自行生成新的图集", remove, total), "确定");
                        DoTexturePacker(folderPath, _targetAtlas.name);
                    }
                }
            }

            EditorGUILayout.LabelField("注意:工具只检测prefab是否引用资源,代码引用判断未处理,请人脑判断");
            EditorGUILayout.LabelField("一键移除,在图集目录新建了一个backups文件夹,并把未引用的png资源文件移动进去");
            EditorGUILayout.LabelField("一键移除后,自行使用TexturePacker 工具重新生成");

            if (_selectHit != null)
            {
                string detail = string.Format("{0}图片 {1}.prefab detail:", _selectSpriteName, _selectHit.prefabName);
                if (EditorHelper.DrawHeader(detail, "detail", false, false))
                {
                    _prefabDetailPos = EditorGUILayout.BeginScrollView(_prefabDetailPos, GUILayout.MinHeight(100f));
                    foreach (string path in _selectHit.hitPathList)
                    {
                        GUILayout.BeginHorizontal("AS TextArea", GUILayout.MinHeight(20f));
                        GUILayout.Space(25f);
                        GUILayout.Label(path);
                        GUILayout.EndHorizontal();
                    }
                    EditorGUILayout.EndScrollView();
                }
            }
            else
            {
                EditorHelper.DrawHeader("none select prefab", "detail", false, false);
            }
        }
        else if (_alreadyCheck)//未生成过manager,表示atlas未被引用过
        {
            if (GUILayout.Button("图集未被引用,点击移除", "LargeButton", GUILayout.Height(50f)))
            {
                if (EditorUtility.DisplayDialog("确认", "此操作会移除图集目录,确认继续?", "确认", "取消"))
                {
                    string atlasPath  = AssetDatabase.GetAssetPath(_targetAtlas);
                    string folderPath = atlasPath.Replace("/" + _targetAtlas.name + ".prefab", "");
                    if (AssetDatabase.MoveAssetToTrash(folderPath))
                    {
                        EditorUtility.DisplayDialog("", "移除图集目录成功", "确认");
                    }
                }
            }
        }
    }