コード例 #1
0
 public static void SetCdnServer(string cdnServer)
 {
     if (cdnServer.IsEmpty())
     {
         return;
     }
     rootPath = GetPath(cdnServer, string.Empty, Platform.platform, TexFormatGroup.GetBest());
 }
コード例 #2
0
ファイル: TexFormatGroupEx.cs プロジェクト: mulova/comunity
 public static void ConvertDependencies(this TexFormatGroup newFormat, string[] assetPaths)
 {
     foreach (string depPath in AssetDatabase.GetDependencies(assetPaths))
     {
         if (depPath.Is(FileType.Image))
         {
             Texture2D tex = AssetDatabase.LoadAssetAtPath <Texture2D>(depPath);
             newFormat.Convert(tex);
         }
     }
 }
コード例 #3
0
ファイル: TexFormatGroupEx.cs プロジェクト: mulova/comunity
 public static TextureImporterFormat GetFormatFromLabel(Texture2D tex, TexFormatGroup group, bool alpha)
 {
     string[] labels = AssetDatabase.GetLabels(tex);
     if (!labels.IsEmpty())
     {
         foreach (string l in labels)
         {
             if (group.IsGroupOf(l))
             {
                 return(EnumUtil.Parse <TextureImporterFormat>(l));
             }
         }
     }
     return(alpha? group.rgba(): group.rgb());
 }
コード例 #4
0
        public static void GetResourceVersion(Action <string> callback)
        {
            string verUrl = string.Format("{0}/version_{1}.txt", Path, TexFormatGroup.GetBest().GetAbCategory(Platform.platform));

            Web.noCache.GetBytes(verUrl, bytes =>
            {
                if (bytes != null)
                {
                    string ver = Encoding.ASCII.GetString(bytes);
                    callback(ver);
                }
                else
                {
                    AssetCache.log.Error("Can't get cdn version from {0}", verUrl);
                    callback(null);
                }
            });
        }
コード例 #5
0
ファイル: TexFormatGroupEx.cs プロジェクト: mulova/comunity
        public static void Convert(this TexFormatGroup format, string folder)
        {
            log.Debug("Converting texture format to '{0}'", format);
            Regex ignore = new Regex("/Editor/|Assets/Plugins/");

            foreach (string p in EditorAssetUtil.ListAssetPaths(folder, FileType.Image))
            {
                if (ignore.IsMatch(p))
                {
                    continue;
                }
                log.Debug(p);
                Texture2D t = AssetDatabase.LoadAssetAtPath <Texture2D>(p);
                if (t != null)
                {
                    format.Convert(t);
                }
            }
        }
コード例 #6
0
 public static string GetPath(string root, string zone, RuntimePlatform platform, TexFormatGroup texFormat)
 {
     return(PathUtil.Combine(root, BuildConfig.BUILD_ID, zone, texFormat.GetAbCategory(platform), BuildConfig.RES_VERSION));
 }
コード例 #7
0
 public static bool IsMemberOf(this TextureImporterFormat format, TexFormatGroup group)
 {
     return(group.IsGroupOf(format));
 }
コード例 #8
0
ファイル: TexFormatGroupEx.cs プロジェクト: mulova/comunity
        public static void Convert(this TexFormatGroup newFormat, Texture2D tex)
        {
            string          path = AssetDatabase.GetAssetPath(tex);
            TextureImporter im   = AssetImporter.GetAtPath(path) as TextureImporter;

            if (im == null || tex.format == TextureFormat.Alpha8)
            {
                return;
            }
            bool changed = false;

            if (newFormat == TexFormatGroup.ASTC && !tex.format.IsASTC())
            {
                im.SetFormat(GetFormatFromLabel(tex, newFormat, tex.format.HasAlpha()));
                changed = true;
            }
            else if (newFormat == TexFormatGroup.ETC2 && !tex.format.IsETC2())
            {
                im.SetFormat(GetFormatFromLabel(tex, newFormat, tex.format.HasAlpha()));
                changed = true;
            }
            else if (newFormat == TexFormatGroup.PVRTC && !tex.format.IsPVRTC())
            {
                if (EditorUserBuildSettings.activeBuildTarget.ToRuntimePlatform().IsIos() &&
#pragma warning disable 0618
                    (im.GetFormat() == TextureImporterFormat.AutomaticCompressed || im.GetFormat() == TextureImporterFormat.AutomaticCrunched))
#pragma warning restore 0618
                {
                    // automatic is the same as PVRTC
                }
                else if (tex.format.HasAlpha())
                {
                    // PVRTC with alpha downgrades the image quality
//					im.textureFormat = TextureImporterFormat.PVRTC_RGB4;
//					changed = true;
                }
                else
                {
                    im.SetFormat(GetFormatFromLabel(tex, newFormat, tex.format.HasAlpha()));
                    changed = true;
                }
            }
            else if (newFormat == TexFormatGroup.ETC && !tex.format.IsETC())
            {
                if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android &&
#pragma warning disable 0618
                    (im.GetFormat() == TextureImporterFormat.AutomaticCompressed || im.GetFormat() == TextureImporterFormat.AutomaticCrunched))
#pragma warning restore 0618
                {
                    // automatic is the same as ETC
                }
                else if (tex.format.HasAlpha())
                {
                    // alpha is not supported in ETC format
                }
                else
                {
                    im.SetFormat(GetFormatFromLabel(tex, newFormat, tex.format.HasAlpha()));
                    changed = true;
                }
#pragma warning disable 0618
            }
            else if (newFormat == TexFormatGroup.AUTO && (im.GetFormat() != TextureImporterFormat.AutomaticCompressed && im.GetFormat() != TextureImporterFormat.AutomaticCrunched))
#pragma warning restore 0618
            {
                if (tex.format.HasAlpha())
                {
                    // compressing alpha
                }
                else
                {
                    im.SetFormat(GetFormatFromLabel(tex, newFormat, tex.format.HasAlpha()));
                    changed = true;
                }
            }
            if (!AssetConfig.TEX_NPOT && im.npotScale == TextureImporterNPOTScale.None && !tex.IsPOT())
            {
                im.npotScale = TextureImporterNPOTScale.ToNearest;
                changed      = true;
            }
            if (changed)
            {
                im.textureType = TextureImporterType.Default;
                im.isReadable  = false;
                AssetDatabase.ImportAsset(path, ImportAssetOptions.ForceUpdate | ImportAssetOptions.ForceSynchronousImport);
            }
        }
コード例 #9
0
ファイル: TexFormatGroupEx.cs プロジェクト: mulova/comunity
 public static TextureImporterFormat rgb(this TexFormatGroup group)
 {
     return(group.ToData().rgb);
 }
コード例 #10
0
ファイル: TexFormatGroupEx.cs プロジェクト: mulova/comunity
 public static bool IsGroupOf(this TexFormatGroup group, string format)
 {
     return(group.ToData().IsGroupOf(format));
 }
コード例 #11
0
ファイル: TexFormatGroupEx.cs プロジェクト: mulova/comunity
 public static bool IsGroupOf(this TexFormatGroup group, TextureImporterFormat format)
 {
     return(group.ToData().IsGroupOf(format));
 }
コード例 #12
0
ファイル: TexFormatGroupEx.cs プロジェクト: mulova/comunity
 public static TexFormatGroupData ToData(this TexFormatGroup format)
 {
     return(TexFormatGroupData.ParseIgnoreCase(format.ToString()));
 }