Пример #1
0
        /// <summary>
        /// 查找模型文件
        /// </summary>
        private void findAllTextures()
        {
            scrollPos = Vector2.zero;
            List <TextureSettingBean> settings = OverviewSetting.Instance.TextureSettings;

            List <string> files = new List <string>();
            Dictionary <TextureSettingBean, string[]> fileMaps = new Dictionary <TextureSettingBean, string[]>();

            List <string> assetTypeList = new List <string>();

            assetTypeList.Add("ALL");

            float fileCount = 0;

            if (settings != null)
            {
                settingMap.Clear();
                for (int i = 0; i < settings.Count; i++)
                {
                    settingMap[settings[i].AssetDesc] = settings[i];
                    files.Clear();
                    for (int j = 0; j < settings[i].Folder.Count; j++)
                    {
                        string rootFolder = settings[i].Folder[j];
                        if (string.IsNullOrEmpty(rootFolder))
                        {
                            continue;
                        }
                        string[] fileArr = Directory.GetFiles(rootFolder, "*.jpg", SearchOption.AllDirectories);
                        files.AddRange(fileArr);
                        fileCount += fileArr.Length;

                        fileArr = Directory.GetFiles(rootFolder, "*.png", SearchOption.AllDirectories);
                        files.AddRange(fileArr);
                        fileCount += fileArr.Length;
                    }
                    fileMaps[settings[i]] = files.ToArray();
                    assetTypeList.Add(settings[i].AssetDesc);
                }
            }

            AssetAllTypes = assetTypeList.ToArray();
            assetList     = new List <TextureBean>();
            int curFileIndex = 0;

            foreach (TextureSettingBean msb in fileMaps.Keys)
            {
                string[] childFiles = fileMaps[msb];
                for (int i = 0; i < childFiles.Length; i++)
                {
                    curFileIndex++;
                    EditorUtility.DisplayProgressBar("分析中", "正在分析贴图数据...", curFileIndex / fileCount);
                    TextureBean asset = parseEffectAsset(childFiles[i]);
                    asset.AssetDesc = msb.AssetDesc;
                    assetList.Add(asset);
                }
            }

            EditorUtility.ClearProgressBar();
        }
Пример #2
0
        private void drawRow(int index, TextureBean asset)
        {
            if (asset.FilePath == GUISetting.SelectFilePath)
            {
                GUI.color = GUISetting.SelectColor;
            }

            if (GUILayout.Button(string.Format("{0}. {1}", index + 1, asset.Name), "OL TextField", GUILayout.MaxWidth(200f)))
            {
                Selection.activeObject    = AssetDatabase.LoadAssetAtPath <Object>(asset.FilePath);
                GUISetting.SelectFilePath = asset.FilePath;
            }

            GUILayout.Space(50);
            GUILayout.Label(asset.AssetDesc, GUILayout.MinWidth(100f));

            GUILayout.Label(asset.Width.ToString(), GUILayout.MinWidth(80F));

            GUILayout.Label(asset.Height.ToString(), GUILayout.MinWidth(80f));

            GUI.color = asset.MipMaps != settingMap[asset.AssetDesc].MipMaps ? Color.red : Color.white;
            GUILayout.Label(asset.MipMaps.ToString(), GUILayout.MinWidth(100F));
            GUI.color = Color.white;

            GUILayout.Label(asset.MaxSize.ToString(), GUILayout.MinWidth(80F));
            GUILayout.Label(asset.Format, GUILayout.MinWidth(100F));

            GUILayout.Label(asset.MemoryText, GUILayout.MinWidth(100F));
            GUI.color = Color.white;
        }
Пример #3
0
        /// <summary>
        /// 分析粒子特效
        /// </summary>
        /// <param name="filePath"></param>
        /// <returns></returns>
        private TextureBean parseEffectAsset(string filePath)
        {
            TextureBean eb = new TextureBean();

            eb.Name     = Path.GetFileName(filePath);
            eb.FilePath = filePath;

            Texture2D tex = AssetDatabase.LoadAssetAtPath <Texture2D>(filePath);

            eb.Width  = tex.width;
            eb.Height = tex.height;
            eb.Format = tex.format.ToString();

            TextureImporter texImp = AssetImporter.GetAtPath(filePath) as TextureImporter;

            eb.MipMaps    = texImp.mipmapEnabled;
            eb.MaxSize    = texImp.maxTextureSize;
            eb.MemorySize = CalculateTextureSizeBytes(tex) / 1024.0f;
            eb.MemoryText = eb.MemorySize >= 1024 ? string.Format("{0:F}MB", eb.MemorySize / 1024)
                            : string.Format("{0:F}KB", eb.MemorySize);
            return(eb);
        }