Example #1
0
        void ProcessAllTex(Texture[] ts)
        {
            EditorUtility.DisplayProgressBar("Searching", "Searching Textures", 0.5f);
            for (int i = 0; i < ts.Length; i++)
            {
                EditorUtility.DisplayProgressBar("Searching", "Searching Textures", 0.5f + 0.5f * (float)i / ts.Length);
                Texture t = ts [i];
                if (t != null)
                {
                    if (!LsyTextureCommon.HasTextureImporter(t))
                    {
                        continue;
                    }

                    var info    = new LsyTextureInfo(t);
                    var setting = info.GetPlatformSetting(platform.ToString());
                    if (above)
                    {
                        if (setting.maxTextureSize >= (int)sizeFilter)
                        {
                            textures.Add(info);
                        }
                    }
                    else
                    {
                        if (setting.maxTextureSize <= (int)sizeFilter)
                        {
                            textures.Add(info);
                        }
                    }
                }
            }
            LocalSearch();
            EditorUtility.ClearProgressBar();
        }
Example #2
0
        void OnGUI_Filter()
        {
            GUILayout.BeginHorizontal();
            GUILayout.Label("最大尺寸", GUILayout.Width(columnWidth));
            sizeFilter = (MaxSize)EditorGUILayout.EnumPopup("", sizeFilter, GUILayout.Width(columnWidth));
            above      = GUILayout.Toggle(above, "以上");
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("搜索文件夹", GUILayout.Width(buttonWidth + 20)))
            {
                Clear();
                EditorUtility.DisplayProgressBar("Searching", "Searching Textures", 0);
                Texture[] ts = Selection.GetFiltered <Texture> (SelectionMode.DeepAssets);
                ProcessAllTex(ts);
            }
            if (GUILayout.Button("搜索场景", GUILayout.Width(buttonWidth + 20)))
            {
                Clear();
                EditorUtility.DisplayProgressBar("Searching", "Searching Textures", 0);
                Texture[] ts = LsyTextureCommon.GetSceneTextures();
                ProcessAllTex(ts);
            }
            if (GUILayout.Button("清除", GUILayout.Width(buttonWidth)))
            {
                Clear();
            }
            GUILayout.EndHorizontal();
        }
Example #3
0
        void OnPreprocessTextureAuto(TextureImporter importer)
        {
            #region PathList
            //Debug.Log (importer.assetPath);
            GetPath();
            string folder = GetFolder(importer.assetPath);
            if (!path.Contains(folder))
            {
                return;
            }
            #endregion

            Dictionary <string, TextureImporterPlatformSettings> dic = new Dictionary <string, TextureImporterPlatformSettings> ();

            LsyTextureInfo info = new LsyTextureInfo(importer, assetPath);

            dic.Add("iPhone", LsyTextureCommon.Create_Setting(info, "iPhone", 1));
            dic.Add("Android", LsyTextureCommon.Create_Setting(info, "Android", 1));

            foreach (var item in dic)
            {
                var oldSettings = importer.GetPlatformTextureSettings(item.Key);
                if (IsSettingRight(oldSettings))
                {
                    continue;
                }
                importer.SetPlatformTextureSettings(item.Value);
            }
        }
Example #4
0
        public void Refresh()
        {
            setting = info.importer.GetPlatformTextureSettings(platform);

            if (info.tex != null)
            {
                SetWidthHeight();
                size = LsyTextureSizeCal.CalculateTextureSizeBytes(info.tex, width, height, setting.format, info.importer.isReadable);
            }
            quality = LsyTextureCommon.GetTexQuality(info, setting.format);
        }
Example #5
0
        void ReimportTexQuality(LsyTextureInfo t, int q)
        {
            //---------------------------------------------
            //同时设置双平台
            //---------------------------------------------
            if (bothSetting)
            {
                var setting1 = LsyTextureCommon.Create_Setting(t, "iPhone", q);
                LsyTextureImporter.ManualSetting = setting1;

                t.importer.SetPlatformTextureSettings(setting1);

                if (t.type == LsyTextureType.shadowmask)
                {
                    t.importer.mipmapEnabled = false;
                }

                ReimportTex(t);
                LsyTextureImporter.ManualSetting = null;


                var setting2 = LsyTextureCommon.Create_Setting(t, "Android", q);
                LsyTextureImporter.ManualSetting = setting2;

                t.importer.SetPlatformTextureSettings(setting2);

                if (t.type == LsyTextureType.shadowmask)
                {
                    t.importer.mipmapEnabled = false;
                }

                ReimportTex(t);
                LsyTextureImporter.ManualSetting = null;
            }


            var setting = LsyTextureCommon.Create_Setting(t, platform.ToString(), q);

            LsyTextureImporter.ManualSetting = setting;

            t.importer.SetPlatformTextureSettings(setting);

            if (t.type == LsyTextureType.shadowmask)
            {
                t.importer.mipmapEnabled = false;
            }

            ReimportTex(t);
            LsyTextureImporter.ManualSetting = null;
        }
Example #6
0
        public void Refresh(bool refreshAll = true)
        {
            if (refreshAll)
            {
                assetPath = AssetDatabase.GetAssetPath(tex);
                importer  = LsyTextureCommon.GetTextureImporter(tex);
            }
            containAlpha = importer.alphaSource != TextureImporterAlphaSource.None;
            //Special Op for exr
            if (assetPath.EndsWith(".exr"))
            {
                containAlpha = false;
            }


            if (importer.textureType == TextureImporterType.Sprite)
            {
                type = LsyTextureType.ui;
            }
            else if (importer.textureType == TextureImporterType.NormalMap)
            {
                type = LsyTextureType.normal;
            }
            else if (assetPath.EndsWith("_shadowmask.png"))
            {
                type = LsyTextureType.shadowmask;
            }
            else if (assetPath.Contains("Impostor"))
            {
                type = LsyTextureType.impostor;
            }
            else
            {
                type = LsyTextureType.tex;
            }

            platformInfos.Clear();
            platformInfos.Add(new LsyTextureInfoPlatform(this, "iPhone"));
            platformInfos.Add(new LsyTextureInfoPlatform(this, "Android"));
        }