Beispiel #1
0
        private void SetDefaultAlpha()
        {
            string[] arrStrPath = Directory.GetFiles(Application.dataPath + "/Resources/atlas/UI/", "*.png", SearchOption.AllDirectories);

            for (int i = 0; i < arrStrPath.Length; ++i)
            {
                string strTempPath = arrStrPath[i].Replace(@"\", "/");
                strTempPath = strTempPath.Substring(strTempPath.IndexOf("Assets"));
                TextureImporter textureImporter = AssetImporter.GetAtPath(strTempPath) as TextureImporter;
                if (textureImporter != null)
                {
                    TextureEditor.ETextureCompress f = TextureEditor.ETextureCompress.Compress;
                    TextureEditor.ETextureSize     s = TextureEditor.ETextureSize.Original;
                    bool isAtlas = TextureEditor.IsAtlas(strTempPath);
                    TextureEditor.GetTexFormat(isAtlas, textureImporter.userData, out f, out s);
                    if (!isAtlas && (f != TextureEditor.ETextureCompress.Compress || s != TextureEditor.ETextureSize.Half))
                    {
                        f = TextureEditor.ETextureCompress.Compress;
                        s = TextureEditor.ETextureSize.Half;
                        textureImporter.userData = string.Format("{0} {1}", (int)f, (int)s);
                        AssetDatabase.ImportAsset(textureImporter.assetPath, ImportAssetOptions.ForceUpdate);
                    }
                }
                EditorUtility.DisplayProgressBar(string.Format("SetDefaultAlpha:{0}/{1}", i, arrStrPath.Length), strTempPath, (float)i / arrStrPath.Length);
            }
            EditorUtility.ClearProgressBar();
            EditorUtility.DisplayDialog("Finish", "All textures processed finish", "OK");
        }
Beispiel #2
0
        private void RefreshTexStatus()
        {
            allTexStatus.Clear();
            string[] arrStrPath = Directory.GetFiles(Application.dataPath + "/Resources/atlas/UI/", "*.png", SearchOption.AllDirectories);
            for (int i = 0; i < arrStrPath.Length; ++i)
            {
                string strTempPath = arrStrPath[i].Replace(@"\", "/");
                strTempPath = strTempPath.Substring(strTempPath.IndexOf("Assets"));
                TextureImporter textureImporter = AssetImporter.GetAtPath(strTempPath) as TextureImporter;
                if (textureImporter != null)
                {
                    TextureEditor.ETextureCompress f = TextureEditor.ETextureCompress.Compress;
                    TextureEditor.ETextureSize     s = TextureEditor.ETextureSize.Original;
                    bool isAtlas = TextureEditor.IsAtlas(strTempPath);
                    TextureEditor.GetTexFormat(isAtlas, textureImporter.userData, out f, out s);

                    if (!TextureEditor.IsDefaultFormat(isAtlas, f, s))
                    {
                        TexInfo tf = new TexInfo();
                        tf.path      = strTempPath;
                        tf.srcFormat = f;
                        tf.alphaSize = s;
                        tf.isAtlas   = isAtlas;
                        allTexStatus.Add(tf);
                    }
                }
            }
            allTexStatus.Sort(CompareNewMsg);
        }