Beispiel #1
0
        void OnGUI()
        {
            CheckerCommonConfig config = CheckerConfigManager.checkerConfig;

            if (config != null)
            {
                config.highlightTextColor             = EditorGUILayout.ColorField("选中文字高亮颜色", config.highlightTextColor);
                config.warningItemColor               = EditorGUILayout.ColorField("警告条目高亮颜色", config.warningItemColor);
                config.sideBarWidth                   = EditorGUILayout.IntSlider("侧边栏宽度", config.sideBarWidth, 180, 300);
                config.autoFilterOnSideBarButtonClick = GUILayout.Toggle(config.autoFilterOnSideBarButtonClick, "点击侧边栏对象自动进行引用筛选", GUILayout.Width(300));
                config.inputType           = (CheckInputMode)EditorGUILayout.Popup("Porject资源检查方式", (int)config.inputType, checkDragTypeStr);
                config.batchOptionType     = (BatchOptionSelection)EditorGUILayout.Popup("批量处理功能处理范围", (int)config.batchOptionType, checkBatchOptionStr);
                config.maxCheckRecordCount = EditorGUILayout.IntSlider("常用查询记录最大值", config.maxCheckRecordCount, 5, 20);
                EditorGUI.BeginChangeCheck();
                exportResultPath = EditorGUILayout.ObjectField("导出检查结果Excel路径", exportResultPath, typeof(Object), false);
                if (EditorGUI.EndChangeCheck())
                {
                    config.checkResultExportPath = AssetDatabase.GetAssetPath(exportResultPath);
                    if (!ResourceCheckerHelper.isFolder(config.checkResultExportPath))
                    {
                        config.checkResultExportPath = "";
                        exportResultPath             = null;
                    }
                }
            }
        }
Beispiel #2
0
        public void SaveCheckFilter()
        {
            predefineFilterGroup = filterItem.SaveAsFilterGroup();
            predefineFilterGroup.filterGroupName = checkerName;
            string path = CheckerConfigManager.configRootPath + CheckerConfigManager.predefineFilterCfgPath;

            if (!ResourceCheckerHelper.isFolder(path))
            {
                AssetDatabase.CreateFolder(CheckerConfigManager.configRootPath, "FilterCfg");
            }
            AssetDatabase.CreateAsset(predefineFilterGroup, path + "/" + predefineFilterGroup.filterGroupName + ".asset");
        }
        public static void MoveAsset()
        {
            if (objectList == null || objectList.Count == 0)
            {
                EditorUtility.DisplayDialog("提示", "当前无选中内容", "OK");
                return;
            }
            if (targetPath == null || !ResourceCheckerHelper.isFolder(AssetDatabase.GetAssetPath(targetPath)))
            {
                EditorUtility.DisplayDialog("提示", "请将要目标文件夹拖入槽内", "OK");
                return;
            }
            string path = AssetDatabase.GetAssetPath(targetPath);

            if (!EditorUtility.DisplayDialog("提示", "选中的文件将被移动到" + path + "文件夹内,请确认", "OK", "Cancle"))
            {
                return;
            }
            List <string> errorList = new List <string>();

            foreach (var obj in objectList)
            {
                string assetPath    = AssetDatabase.GetAssetPath(obj);
                string assetName    = System.IO.Path.GetFileName(assetPath);
                string newAssetPath = path + "/" + assetName;
                if (assetPath == newAssetPath)
                {
                    Debug.Log("Dest path has the same name resource : " + assetPath);
                    errorList.Add(assetPath);
                    continue;
                }
                AssetDatabase.MoveAsset(assetPath, newAssetPath);
            }
            if (errorList.Count > 0)
            {
                string errorLog = "文件:";
                foreach (var s in errorList)
                {
                    errorLog += s + "\n";
                }
                errorLog += "移动失败,目标路径已包含同名文件,请手动确认并移动";
                EditorUtility.DisplayDialog("提示", errorLog, "OK");
            }
            AssetDatabase.Refresh();
        }
Beispiel #4
0
        public static List <Object> GetAllObjectFromInput <T>(Object[] objects, string filter) where T : Object
        {
            List <string> pathFolderList = new List <string>();
            List <Object> objlist        = new List <Object>();
            List <string> singleObjList  = new List <string>();

            for (int i = 0; i < objects.Length; i++)
            {
                Object obj = objects[i];
                if (obj == null)
                {
                    continue;
                }
                string temPath = AssetDatabase.GetAssetPath(obj);
                if (ResourceCheckerHelper.isFolder(temPath))
                {
                    pathFolderList.Add(temPath);
                }
                else if (obj is T)
                {
                    objlist.Add(obj);
                }
            }
            if (pathFolderList.Count > 0)
            {
                string[] guids = AssetDatabase.FindAssets(filter, pathFolderList.ToArray());
                singleObjList.AddRange(guids.Select(x => AssetDatabase.GUIDToAssetPath(x)));
            }

            for (int i = 0; i < singleObjList.Count; i++)
            {
                string s = singleObjList[i];
                if (EditorUtility.DisplayCancelableProgressBar("正在加载" + filter + "类型资源", "已完成:" + i + "/" + singleObjList.Count, (float)i / singleObjList.Count))
                {
                    break;
                }
                objlist.Add(AssetDatabase.LoadAssetAtPath <T>(s));
            }
            EditorUtility.ClearProgressBar();
            return(objlist);
        }