Ejemplo n.º 1
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
            }
Ejemplo n.º 2
0
 public TextureDetail(Object obj, TextureChecker checker) : base(obj, checker)
 {
 }