public override string GetInfoString() { Texture target = base.target as Texture; Texture2D t = base.target as Texture2D; TextureImporter atPath = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(target)) as TextureImporter; string str = target.width.ToString() + "x" + target.height.ToString(); if (QualitySettings.desiredColorSpace == ColorSpace.Linear) { str = str + " " + TextureUtil.GetTextureColorSpaceString(target); } bool flag = true; bool flag2 = (atPath != null) && atPath.qualifiesForSpritePacking; bool flag3 = IsNormalMap(target); bool flag4 = TextureUtil.DoesTextureStillNeedToBeCompressed(AssetDatabase.GetAssetPath(target)); bool flag5 = (t != null) && TextureUtil.IsNonPowerOfTwo(t); TextureFormat textureFormat = TextureUtil.GetTextureFormat(target); flag = !flag4; if (flag5) { str = str + " (NPOT)"; } if (flag4) { str = str + " (Not yet compressed)"; } else if (!flag3) { if (flag2) { TextureFormat format2; ColorSpace space; int num3; atPath.ReadTextureImportInstructions(EditorUserBuildSettings.activeBuildTarget, out format2, out space, out num3); string str2 = str; string[] textArray1 = new string[] { str2, "\n ", TextureUtil.GetTextureFormatString(textureFormat), "(Original) ", TextureUtil.GetTextureFormatString(format2), "(Atlas)" }; str = string.Concat(textArray1); } else { str = str + " " + TextureUtil.GetTextureFormatString(textureFormat); } } else { switch (textureFormat) { case TextureFormat.ARGB4444: str = str + " Nm 16 bit"; goto Label_01EF; case TextureFormat.RGBA32: case TextureFormat.ARGB32: str = str + " Nm 32 bit"; goto Label_01EF; } if (textureFormat == TextureFormat.DXT5) { str = str + " DXTnm"; } else { str = str + " " + TextureUtil.GetTextureFormatString(textureFormat); } } Label_01EF: if (flag) { str = str + "\n" + EditorUtility.FormatBytes(TextureUtil.GetStorageMemorySize(target)); } if (TextureUtil.GetUsageMode(target) != TextureUsageMode.AlwaysPadded) { return(str); } int gPUWidth = TextureUtil.GetGPUWidth(target); int gPUHeight = TextureUtil.GetGPUHeight(target); if ((target.width == gPUWidth) && (target.height == gPUHeight)) { return(str); } return(str + $" Padded to {gPUWidth}x{gPUHeight}"); }
public override string GetInfoString() { Texture texture = base.target as Texture; Texture2D texture2D = base.target as Texture2D; TextureImporter textureImporter = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(texture)) as TextureImporter; string text = texture.width.ToString() + "x" + texture.height.ToString(); if (QualitySettings.desiredColorSpace == ColorSpace.Linear) { text = text + " " + TextureUtil.GetTextureColorSpaceString(texture); } bool flag = textureImporter && textureImporter.qualifiesForSpritePacking; bool flag2 = TextureInspector.IsNormalMap(texture); bool flag3 = TextureUtil.DoesTextureStillNeedToBeCompressed(AssetDatabase.GetAssetPath(texture)); bool flag4 = texture2D != null && TextureUtil.IsNonPowerOfTwo(texture2D); TextureFormat textureFormat = TextureUtil.GetTextureFormat(texture); bool flag5 = !flag3; if (flag4) { text += " (NPOT)"; } if (flag3) { text += " (Not yet compressed)"; } else if (flag2) { switch (textureFormat) { case TextureFormat.ARGB4444: text += " Nm 16 bit"; goto IL_176; case TextureFormat.RGB24: IL_11D: if (textureFormat != TextureFormat.DXT5) { text = text + " " + TextureUtil.GetTextureFormatString(textureFormat); goto IL_176; } text += " DXTnm"; goto IL_176; case TextureFormat.RGBA32: case TextureFormat.ARGB32: text += " Nm 32 bit"; goto IL_176; } goto IL_11D; IL_176 :; } else if (flag) { TextureFormat format; ColorSpace colorSpace; int num; textureImporter.ReadTextureImportInstructions(EditorUserBuildSettings.activeBuildTarget, out format, out colorSpace, out num); string text2 = text; text = string.Concat(new string[] { text2, "\n ", TextureUtil.GetTextureFormatString(textureFormat), "(Original) ", TextureUtil.GetTextureFormatString(format), "(Atlas)" }); } else { text = text + " " + TextureUtil.GetTextureFormatString(textureFormat); } if (flag5) { text = text + "\n" + EditorUtility.FormatBytes(TextureUtil.GetStorageMemorySizeLong(texture)); } if (TextureUtil.GetUsageMode(texture) == TextureUsageMode.AlwaysPadded) { int gPUWidth = TextureUtil.GetGPUWidth(texture); int gPUHeight = TextureUtil.GetGPUHeight(texture); if (texture.width != gPUWidth || texture.height != gPUHeight) { text += string.Format("\nPadded to {0}x{1}", gPUWidth, gPUHeight); } } return(text); }
public override string GetInfoString() { // TextureInspector code is reused for RenderTexture and Cubemap inspectors. // Make sure we can handle the situation where target is just a Texture and // not a Texture2D. Texture t = target as Texture; Texture2D t2 = target as Texture2D; TextureImporter textureImporter = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(t)) as TextureImporter; string info = t.width + "x" + t.height; bool showSize = true; bool isPackedSprite = textureImporter && textureImporter.qualifiesForSpritePacking; bool isNormalmap = IsNormalMap(t); bool stillNeedsCompression = TextureUtil.DoesTextureStillNeedToBeCompressed(AssetDatabase.GetAssetPath(t)); bool isNPOT = t2 != null && TextureUtil.IsNonPowerOfTwo(t2); GraphicsFormat format = t.graphicsFormat; showSize = !stillNeedsCompression; if (isNPOT) { info += " (NPOT)"; } if (stillNeedsCompression) { info += " (Not yet compressed)"; } else { if (isNormalmap) { switch (format) { case GraphicsFormat.RGBA_DXT5_SRGB: case GraphicsFormat.RGBA_DXT5_UNorm: info += " DXTnm"; break; case GraphicsFormat.R8G8B8A8_SRGB: case GraphicsFormat.R8G8B8A8_UNorm: case GraphicsFormat.B8G8R8A8_SRGB: case GraphicsFormat.B8G8R8A8_UNorm: info += " Nm 32 bit"; break; case GraphicsFormat.R4G4B4A4_UNormPack16: case GraphicsFormat.B4G4R4A4_UNormPack16: info += " Nm 16 bit"; break; default: info += " " + GraphicsFormatUtility.GetFormatString(format); break; } } else if (isPackedSprite) { TextureFormat desiredFormat; ColorSpace dummyColorSpace; int dummyComressionQuality; textureImporter.ReadTextureImportInstructions(EditorUserBuildSettings.activeBuildTarget, out desiredFormat, out dummyColorSpace, out dummyComressionQuality); info += "\n " + GraphicsFormatUtility.GetFormatString(format) + "(Original) " + TextureUtil.GetTextureFormatString(desiredFormat) + "(Atlas)"; } else { info += " " + GraphicsFormatUtility.GetFormatString(format); } } if (showSize) { info += "\n" + EditorUtility.FormatBytes(TextureUtil.GetStorageMemorySizeLong(t)); } if (TextureUtil.GetUsageMode(t) == TextureUsageMode.AlwaysPadded) { var glWidth = TextureUtil.GetGPUWidth(t); var glHeight = TextureUtil.GetGPUHeight(t); if (t.width != glWidth || t.height != glHeight) { info += UnityString.Format("\nPadded to {0}x{1}", glWidth, glHeight); } } else if (TextureUtil.GetUsageMode(t) == TextureUsageMode.BakedLightmapRGBM || TextureUtil.GetUsageMode(t) == TextureUsageMode.RealtimeLightmapRGBM || TextureUtil.GetUsageMode(t) == TextureUsageMode.RGBMEncoded) { info += "\nRGBM encoded"; } else if (TextureUtil.GetUsageMode(t) == TextureUsageMode.DoubleLDR || TextureUtil.GetUsageMode(t) == TextureUsageMode.BakedLightmapDoubleLDR) { info += "\ndLDR encoded"; } return(info); }