Example #1
0
    //展示检测出的数据
    void ShowRepetitive(repetitiveInfo target_info, int index)
    {
        GUILayout.Space(10);
        string use_txt        = target_info.useed_path_list.Count == 0 ? " 没有引用" : " ";
        string repetitive_txt = target_info.repetitive_list.Count == 0 ? " " : " 有重复资源";

        allfoldouttype[index - 1] = EditorGUILayout.Foldout(allfoldouttype[index - 1], "目标资源:" + target_info.obj.name
                                                            + use_txt + repetitive_txt);
        if (allfoldouttype[index - 1])
        {
            GUILayout.BeginVertical();

            EditorGUILayout.ObjectField(target_info.obj, typeof(UnityEngine.Object), true);

            if (target_info.useed_path_list.Count == 0) //没有引用
            {
                GUILayout.Label("该资源没有被引用", GUILayout.Width(150));
            }
            else
            {
                GUILayout.Label("该目标资源存在的引用: ", GUILayout.Width(150));
                for (int j = 0; j < target_info.useed_path_list.Count; j++)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("  " + (j + 1) + ".", GUILayout.Width(20));
                    EditorGUILayout.ObjectField(target_info.useed_path_list[j], typeof(UnityEngine.Object), false);
                    GUILayout.EndHorizontal();
                }
            }

            for (int i = 0; i < target_info.repetitive_list.Count; i++)
            {
                repetitiveInfo now_info = target_info.repetitive_list[i];

                GUILayout.BeginVertical();
                GUILayout.BeginHorizontal();
                GUILayout.Label("重复资源 NO" + (i + 1), GUILayout.Width(150));
                EditorGUILayout.ObjectField(now_info.obj, typeof(UnityEngine.Object), true);
                GUILayout.EndHorizontal();
                GUILayout.Label("该重复资源存在的引用: ", GUILayout.Width(150));
                for (int j = 0; j < now_info.useed_path_list.Count; j++)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("  " + (j + 1) + ".", GUILayout.Width(20));
                    EditorGUILayout.ObjectField(now_info.useed_path_list[j], typeof(UnityEngine.Object), false);
                    GUILayout.EndHorizontal();
                }
                GUILayout.EndVertical();
            }
            GUILayout.EndVertical();
        }
    }
Example #2
0
    //遍历整个工程的图片
    void CheckAllAssetsTexture()
    {
        for (int i = 0; i < allTargetInfos.Count; i++)
        {
            allfoldouttype.Add(false);
            repetitiveInfo target_info = allTargetInfos[i];
            isChecking = EditorUtility.DisplayCancelableProgressBar("匹配资源中", target_info.obj.name, i / allTargetInfos.Count);
            for (int j = 0; j < allTexbit.Count; j++)
            {
                if (target_info.bitmap.Equals(allTexbit[j]) && !target_info.path.Equals(filePaths[j]))
                {
#if UNITY_EDITOR
                    UnityEngine.Object assetObj = AssetDatabase.LoadAssetAtPath <UnityEngine.Object>(filePaths[j]);
                    if (null != assetObj)
                    {
                        repetitiveInfo info;
                        info.obj             = assetObj;
                        info.bitmap          = allTexbit[j];
                        info.path            = filePaths[j];
                        info.useed_path_list = new List <UnityEngine.Object>();//Find(info.path);
                        info.repetitive_list = null;
                        target_info.repetitive_list.Add(info);
                        all_need_find_list.Add(info);
                    }
#endif
                }
                else
                {
                }
            }
        }
        FindUse();
        EditorUtility.ClearProgressBar();
        isChecking = false;

        OnGUI();
    }