示例#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;
                    }
                }
            }
        }
示例#2
0
        private void ExportCurrentCheckerResult()
        {
            string path = ResourceCheckerHelper.GenericExportFolderName();

            Directory.CreateDirectory(path);
            ExportCheckResult(path);
            AssetDatabase.Refresh();
        }
        public void ExportAllActiveCheckerResult()
        {
            string path = ResourceCheckerHelper.GenericExportFolderName();

            Directory.CreateDirectory(path);
            activeCheckerList.ForEach(x => x.ExportCheckResult(path));
            AssetDatabase.Refresh();
        }
示例#4
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();
        }
示例#6
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);
        }
示例#7
0
            public override void InitDetailCheckObject(Object obj)
            {
                AudioClip    clip               = obj as AudioClip;
                AudioChecker checker            = currentChecker as AudioChecker;
                string       compression        = buildInType;
                int          quality            = 0;
                string       sampleRateSetting  = buildInType;
                int          overrideSampleRate = 0;

                string androidOverride          = buildInType;
                string androidLoadType          = buildInType;
                string androidCompression       = buildInType;
                int    androidQuality           = 0;
                string androidSampleRateSetting = buildInType;
                int    androidSampleRate        = 0;

                string iosOverride          = buildInType;
                string iosLoadType          = buildInType;
                string iosCompression       = buildInType;
                int    iosQuality           = 0;
                string iosSampleRateSetting = buildInType;
                int    iosSampleRate        = 0;

                AudioImporter importer = AudioImporter.GetAtPath(assetPath) as AudioImporter;

                if (importer != null)
                {
                    compression        = importer.defaultSampleSettings.compressionFormat.ToString();
                    quality            = Mathf.Clamp((int)(importer.defaultSampleSettings.quality * 100), 1, 100);
                    sampleRateSetting  = importer.defaultSampleSettings.sampleRateSetting.ToString();
                    overrideSampleRate = (int)importer.defaultSampleSettings.sampleRateOverride;

                    AudioImporterSampleSettings androidSettings = importer.GetOverrideSampleSettings(platformAndroid);
                    androidOverride          = importer.ContainsSampleSettingsOverride(platformAndroid).ToString();
                    androidLoadType          = androidSettings.loadType.ToString();
                    androidCompression       = androidSettings.compressionFormat.ToString();
                    androidQuality           = Mathf.Clamp((int)(androidSettings.quality * 100), 1, 100);
                    androidSampleRateSetting = androidSettings.sampleRateSetting.ToString();
                    androidSampleRate        = (int)androidSettings.sampleRateOverride;

                    AudioImporterSampleSettings iosSettings = importer.GetOverrideSampleSettings(platformIOS);
                    iosOverride          = importer.ContainsSampleSettingsOverride(platformIOS).ToString();
                    iosLoadType          = iosSettings.loadType.ToString();
                    iosCompression       = iosSettings.compressionFormat.ToString();
                    iosQuality           = Mathf.Clamp((int)(iosSettings.quality * 100), 1, 100);
                    iosSampleRateSetting = iosSettings.sampleRateSetting.ToString();
                    iosSampleRate        = (int)iosSettings.sampleRateOverride;
                }
                checkMap.Add(checker.audioLength, clip.length);
                checkMap.Add(checker.audioType, clip.loadType.ToString());
                checkMap.Add(checker.audioChannel, clip.channels);
                checkMap.Add(checker.audioCompression, compression);
                checkMap.Add(checker.audioQuality, quality);
                checkMap.Add(checker.audioSampleRateSetting, sampleRateSetting);
                checkMap.Add(checker.audioSampleRate, overrideSampleRate);
                checkMap.Add(checker.audioPostfix, ResourceCheckerHelper.GetAssetPostfix(assetPath));

                checkMap.Add(checker.audioAndroidOverride, androidOverride);
                checkMap.Add(checker.audioAndroidLoadType, androidLoadType);
                checkMap.Add(checker.audioAndroidCompressionFormat, androidCompression);
                checkMap.Add(checker.audioAndroidQuality, androidQuality);
                checkMap.Add(checker.audioAndroidSampleRateSetting, androidSampleRateSetting);
                checkMap.Add(checker.audioAndroidSampleRate, androidSampleRate);

                checkMap.Add(checker.audioIOSOverride, iosOverride);
                checkMap.Add(checker.audioIOSLoadType, iosLoadType);
                checkMap.Add(checker.audioIOSCompressionFormat, iosCompression);
                checkMap.Add(checker.audioIOSQuality, iosQuality);
                checkMap.Add(checker.audioIOSSampleRateSetting, iosSampleRateSetting);
                checkMap.Add(checker.audioIOSSampleRate, iosSampleRate);
            }
示例#8
0
            public override void InitDetailCheckObject(Object obj)
            {
                TextureChecker checker = currentChecker as TextureChecker;
                Texture        tex     = obj as Texture;
                string         format  = "Special";

                if (tex is Texture2D)
                {
                    Texture2D tex2D = tex as Texture2D;
                    format = tex2D.format + "\n" + tex2D.width + " x " + tex2D.height + " " + tex2D.mipmapCount + "mip ";
                }
                else if (tex is Cubemap)
                {
                    Cubemap texCube = tex as Cubemap;
                    format = texCube.format + "\n" + tex.width + " x " + tex.height + " x6 ";
                }

                TextureImporter texImporter = TextureImporter.GetAtPath(assetPath) as TextureImporter;
                string          mip         = buildInType;
                string          readable    = buildInType;
                string          type        = buildInType;
                string          npotScale   = buildInType;
                int             anisoLevel  = 1;
                int             texOriSize  = 0;

                string androidOverride        = buildInType;
                int    androidMaxSize         = 0;
                string androidFormat          = buildInType;
                string androidCompressQuality = buildInType;

                string iosOverride        = buildInType;
                int    iosMaxSize         = 0;
                string iosFormat          = buildInType;
                string iosCompressQuality = buildInType;

#if UNITY_5_5_OR_NEWER
                string alpha       = buildInType;
                string compression = buildInType;
#else
                string alphaFromGray = buildInType;
                string alphaIsTran   = buildInType;
                string sourceAlpha   = buildInType;
#endif
                if (texImporter)
                {
                    mip        = texImporter.mipmapEnabled.ToString();
                    readable   = texImporter.isReadable.ToString();
                    type       = texImporter.textureType.ToString();
                    npotScale  = texImporter.npotScale.ToString();
                    anisoLevel = texImporter.anisoLevel;
                    texOriSize = GetOriTextureSize(texImporter);
#if UNITY_5_5_OR_NEWER
                    TextureImporterPlatformSettings androidsettings = texImporter.GetPlatformTextureSettings(platformAndroid);
                    androidOverride        = androidsettings.overridden.ToString();
                    androidMaxSize         = androidsettings.maxTextureSize;
                    androidFormat          = androidsettings.format.ToString();
                    androidCompressQuality = GetCompressionQuality(androidsettings.compressionQuality);

                    TextureImporterPlatformSettings iossettings = texImporter.GetPlatformTextureSettings(platformIOS);
                    iosOverride        = iossettings.overridden.ToString();
                    iosMaxSize         = iossettings.maxTextureSize;
                    iosFormat          = iossettings.format.ToString();
                    iosCompressQuality = GetCompressionQuality(iossettings.compressionQuality);

                    alpha       = texImporter.alphaSource.ToString();
                    compression = texImporter.textureCompression.ToString();
#else
                    TextureImporterFormat androidImportFormat;
                    int androidImportCompressionQa;
                    androidOverride        = texImporter.GetPlatformTextureSettings(platformAndroid, out androidMaxSize, out androidImportFormat, out androidImportCompressionQa).ToString();
                    androidFormat          = androidImportFormat.ToString();
                    androidCompressQuality = GetCompressionQuality(androidImportCompressionQa);

                    TextureImporterFormat iosImportFormat;
                    int iosImportCompressionQa;
                    iosOverride        = texImporter.GetPlatformTextureSettings(platformIOS, out iosMaxSize, out iosImportFormat, out iosImportCompressionQa).ToString();
                    iosFormat          = iosImportFormat.ToString();
                    iosCompressQuality = GetCompressionQuality(iosImportCompressionQa);

                    alphaFromGray = texImporter.grayscaleToAlpha.ToString();
                    alphaIsTran   = texImporter.alphaIsTransparency.ToString();
                    //5.5之前可以用
                    sourceAlpha = texImporter.DoesSourceTextureHaveAlpha().ToString();
#endif
                }
                int    memSize      = CalculateTextureSizeBytes(tex) / 1024;
                int    size         = Mathf.Max(tex.width, tex.height);
                bool   isSquare     = tex.width == tex.height;
                bool   isPoworOfTwo = TextureIsPowerOfTwo(tex);
                string postfix      = ResourceCheckerHelper.GetAssetPostfix(assetPath);
                checkMap.Add(checker.texFormat, format);
                checkMap.Add(checker.texMipmap, mip);
                checkMap.Add(checker.texReadable, readable);
                checkMap.Add(checker.texType, type);
                checkMap.Add(checker.texMemSize, memSize);
                checkMap.Add(checker.texSize, size);
                checkMap.Add(checker.texPostfix, postfix);
                checkMap.Add(checker.texAnisoLevel, anisoLevel);
                checkMap.Add(checker.texIsSquareMap, isSquare.ToString());
                checkMap.Add(checker.texNonPowerOfTwo, isPoworOfTwo.ToString());
                checkMap.Add(checker.texNpotScale, npotScale);
                checkMap.Add(checker.texWrapMode, tex.wrapMode.ToString());
                checkMap.Add(checker.texFilterMode, tex.filterMode.ToString());
                checkMap.Add(checker.texOriSize, texOriSize);

                checkMap.Add(checker.texAndroidOverride, androidOverride);
                checkMap.Add(checker.texAndroidMaxSize, androidMaxSize);
                checkMap.Add(checker.texAndroidFormat, androidFormat);
                checkMap.Add(checker.texAndroidCompressQuality, androidCompressQuality);

                checkMap.Add(checker.texIOSOverride, iosOverride);
                checkMap.Add(checker.texIOSMaxSize, iosMaxSize);
                checkMap.Add(checker.texIOSFormat, iosFormat);
                checkMap.Add(checker.texIOSCompressQuality, iosCompressQuality);
#if UNITY_5_5_OR_NEWER
                checkMap.Add(checker.texAlpha, alpha);
                checkMap.Add(checker.texCompression, compression);
#else
                checkMap.Add(checker.texAlphaFromGray, alphaFromGray);
                checkMap.Add(checker.texAlphaIsTransparent, alphaIsTran);
                checkMap.Add(checker.texSourceAlpha, sourceAlpha);
#endif
            }