GetStorageMemorySize() private method

private GetStorageMemorySize ( Texture t ) : int
t UnityEngine.Texture
return int
コード例 #1
0
        private void Summary()
        {
            GUILayout.BeginVertical(EditorStyles.helpBox, new GUILayoutOption[0]);
            int bytes = 0;
            int num   = 0;
            Dictionary <Vector2, int> dictionary1 = new Dictionary <Vector2, int>();
            bool flag1 = false;

            foreach (LightmapData lightmap in LightmapSettings.lightmaps)
            {
                if (!((UnityEngine.Object)lightmap.lightmapFar == (UnityEngine.Object)null))
                {
                    ++num;
                    Vector2 key = new Vector2((float)lightmap.lightmapFar.width, (float)lightmap.lightmapFar.height);
                    if (dictionary1.ContainsKey(key))
                    {
                        Dictionary <Vector2, int> dictionary2;
                        Vector2 index;
                        (dictionary2 = dictionary1)[index = key] = dictionary2[index] + 1;
                    }
                    else
                    {
                        dictionary1.Add(key, 1);
                    }
                    bytes += TextureUtil.GetStorageMemorySize((Texture)lightmap.lightmapFar);
                    if ((bool)((UnityEngine.Object)lightmap.lightmapNear))
                    {
                        bytes += TextureUtil.GetStorageMemorySize((Texture)lightmap.lightmapNear);
                        flag1  = true;
                    }
                }
            }
            string str   = num.ToString() + (!flag1 ? " non-directional" : " directional") + " lightmap" + (num != 1 ? "s" : string.Empty);
            bool   flag2 = true;

            using (Dictionary <Vector2, int> .Enumerator enumerator = dictionary1.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    KeyValuePair <Vector2, int> current = enumerator.Current;
                    str  += !flag2 ? ", " : ": ";
                    flag2 = false;
                    if (current.Value > 1)
                    {
                        str = str + (object)current.Value + "x";
                    }
                    str = str + (object)current.Key.x + "x" + (object)current.Key.y + "px";
                }
            }
            GUILayout.BeginHorizontal();
            GUILayout.BeginVertical();
            GUILayout.Label(str + " ", LightingWindow.styles.labelStyle, new GUILayoutOption[0]);
            GUILayout.EndVertical();
            GUILayout.BeginVertical();
            GUILayout.Label(EditorUtility.FormatBytes(bytes), LightingWindow.styles.labelStyle, new GUILayoutOption[0]);
            GUILayout.Label(num != 0 ? string.Empty : "No Lightmaps", LightingWindow.styles.labelStyle, new GUILayoutOption[0]);
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
        }
コード例 #2
0
        private void Summary()
        {
            GUILayout.BeginVertical(EditorStyles.helpBox, new GUILayoutOption[0]);
            int bytes = 0;
            int num2  = 0;
            Dictionary <Vector2, int> dictionary = new Dictionary <Vector2, int>();
            bool flag = false;

            foreach (LightmapData data in LightmapSettings.lightmaps)
            {
                if (data.lightmapFar != null)
                {
                    num2++;
                    Vector2 key = new Vector2((float)data.lightmapFar.width, (float)data.lightmapFar.height);
                    if (dictionary.ContainsKey(key))
                    {
                        Dictionary <Vector2, int> dictionary2;
                        Vector2 vector2;
                        int     num4 = dictionary2[vector2];
                        (dictionary2 = dictionary)[vector2 = key] = num4 + 1;
                    }
                    else
                    {
                        dictionary.Add(key, 1);
                    }
                    bytes += TextureUtil.GetStorageMemorySize(data.lightmapFar);
                    if (data.lightmapNear != null)
                    {
                        bytes += TextureUtil.GetStorageMemorySize(data.lightmapNear);
                        flag   = true;
                    }
                }
            }
            object[] objArray1 = new object[] { num2, !flag ? " non-directional" : " directional", " lightmap", (num2 != 1) ? "s" : string.Empty };
            string   str       = string.Concat(objArray1);
            bool     flag2     = true;

            foreach (KeyValuePair <Vector2, int> pair in dictionary)
            {
                str   = str + (!flag2 ? ", " : ": ");
                flag2 = false;
                if (pair.Value > 1)
                {
                    str = str + pair.Value + "x";
                }
                string   str2      = str;
                object[] objArray2 = new object[] { str2, pair.Key.x, "x", pair.Key.y, "px" };
                str = string.Concat(objArray2);
            }
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.BeginVertical(new GUILayoutOption[0]);
            GUILayout.Label(str + " ", styles.labelStyle, new GUILayoutOption[0]);
            GUILayout.EndVertical();
            GUILayout.BeginVertical(new GUILayoutOption[0]);
            GUILayout.Label(EditorUtility.FormatBytes(bytes), styles.labelStyle, new GUILayoutOption[0]);
            GUILayout.Label((num2 != 0) ? string.Empty : "No Lightmaps", styles.labelStyle, new GUILayoutOption[0]);
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
        }
コード例 #3
0
        private void Summary()
        {
            GUILayout.BeginVertical(EditorStyles.helpBox, new GUILayoutOption[0]);
            int num  = 0;
            int num2 = 0;
            Dictionary <Vector2, int> dictionary = new Dictionary <Vector2, int>();
            bool flag = false;

            LightmapData[] lightmaps = LightmapSettings.lightmaps;
            for (int i = 0; i < lightmaps.Length; i++)
            {
                LightmapData lightmapData = lightmaps[i];
                if (!(lightmapData.lightmapFar == null))
                {
                    num2++;
                    Vector2 vector = new Vector2((float)lightmapData.lightmapFar.width, (float)lightmapData.lightmapFar.height);
                    if (dictionary.ContainsKey(vector))
                    {
                        Dictionary <Vector2, int> dictionary2;
                        Dictionary <Vector2, int> expr_7C = dictionary2 = dictionary;
                        Vector2 key;
                        Vector2 expr_81 = key = vector;
                        int     num3    = dictionary2[key];
                        expr_7C[expr_81] = num3 + 1;
                    }
                    else
                    {
                        dictionary.Add(vector, 1);
                    }
                    num += TextureUtil.GetStorageMemorySize(lightmapData.lightmapFar);
                    if (lightmapData.lightmapNear)
                    {
                        num += TextureUtil.GetStorageMemorySize(lightmapData.lightmapNear);
                        flag = true;
                    }
                }
            }
            string text = string.Concat(new object[]
            {
                num2,
                (!flag) ? " non-directional" : " directional",
                " lightmap",
                (num2 != 1) ? "s" : string.Empty
            });
            bool flag2 = true;

            foreach (KeyValuePair <Vector2, int> current in dictionary)
            {
                text += ((!flag2) ? ", " : ": ");
                flag2 = false;
                if (current.Value > 1)
                {
                    text = text + current.Value + "x";
                }
                string text2 = text;
                text = string.Concat(new object[]
                {
                    text2,
                    current.Key.x,
                    "x",
                    current.Key.y,
                    "px"
                });
            }
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.BeginVertical(new GUILayoutOption[0]);
            GUILayout.Label(text + " ", LightingWindow.styles.labelStyle, new GUILayoutOption[0]);
            GUILayout.EndVertical();
            GUILayout.BeginVertical(new GUILayoutOption[0]);
            GUILayout.Label(EditorUtility.FormatBytes(num), LightingWindow.styles.labelStyle, new GUILayoutOption[0]);
            GUILayout.Label((num2 != 0) ? string.Empty : "No Lightmaps", LightingWindow.styles.labelStyle, new GUILayoutOption[0]);
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
        }
コード例 #4
0
        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}");
        }
コード例 #5
0
        public override string GetInfoString()
        {
            Texture   texture   = this.target as Texture;
            Texture2D texture2D = this.target as Texture2D;
            string    text      = texture.width.ToString() + "x" + texture.height.ToString();

            if (QualitySettings.desiredColorSpace == ColorSpace.Linear)
            {
                text = text + " " + TextureUtil.GetTextureColorSpaceString(texture);
            }
            bool          flag          = TextureInspector.IsNormalMap(texture);
            bool          flag2         = TextureUtil.DoesTextureStillNeedToBeCompressed(AssetDatabase.GetAssetPath(texture));
            bool          flag3         = texture2D != null && TextureUtil.IsNonPowerOfTwo(texture2D);
            TextureFormat textureFormat = TextureUtil.GetTextureFormat(texture);
            bool          flag4         = !flag2;

            if (flag3)
            {
                text += " (NPOT)";
            }
            if (flag2)
            {
                text += " (Not yet compressed)";
            }
            else
            {
                if (flag)
                {
                    TextureFormat textureFormat2 = textureFormat;
                    switch (textureFormat2)
                    {
                    case TextureFormat.ARGB4444:
                        text += "  Nm 16 bit";
                        goto IL_142;

                    case TextureFormat.RGB24:
                    case TextureFormat.RGBA32:
IL_E9:
                        if (textureFormat2 != TextureFormat.DXT5)
                        {
                            text = text + "  " + TextureUtil.GetTextureFormatString(textureFormat);
                            goto IL_142;
                        }
                        text += "  DXTnm";
                        goto IL_142;

                    case TextureFormat.ARGB32:
                        text += "  Nm 32 bit";
                        goto IL_142;
                    }
                    goto IL_E9;
                    IL_142 :;
                }
                else
                {
                    text = text + "  " + TextureUtil.GetTextureFormatString(textureFormat);
                }
            }
            if (flag4)
            {
                text = text + "\n" + EditorUtility.FormatBytes(TextureUtil.GetStorageMemorySize(texture));
            }
            if (TextureUtil.GetUsageMode(texture) == TextureUsageMode.AlwaysPadded)
            {
                int gLWidth  = TextureUtil.GetGLWidth(texture);
                int gLHeight = TextureUtil.GetGLHeight(texture);
                if (texture.width != gLWidth || texture.height != gLHeight)
                {
                    text += string.Format("\nPadded to {0}x{1}", gLWidth, gLHeight);
                }
            }
            return(text);
        }
コード例 #6
0
        public override string GetInfoString()
        {
            Texture         target1 = this.target as Texture;
            Texture2D       target2 = this.target as Texture2D;
            TextureImporter atPath  = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath((UnityEngine.Object)target1)) as TextureImporter;
            string          str1    = target1.width.ToString() + "x" + target1.height.ToString();

            if (QualitySettings.desiredColorSpace == ColorSpace.Linear)
            {
                str1 = str1 + " " + TextureUtil.GetTextureColorSpaceString(target1);
            }
            bool          flag1          = (bool)((UnityEngine.Object)atPath) && atPath.qualifiesForSpritePacking;
            bool          flag2          = TextureInspector.IsNormalMap(target1);
            bool          beCompressed   = TextureUtil.DoesTextureStillNeedToBeCompressed(AssetDatabase.GetAssetPath((UnityEngine.Object)target1));
            bool          flag3          = (UnityEngine.Object)target2 != (UnityEngine.Object)null && TextureUtil.IsNonPowerOfTwo(target2);
            TextureFormat textureFormat1 = TextureUtil.GetTextureFormat(target1);
            bool          flag4          = !beCompressed;

            if (flag3)
            {
                str1 += " (NPOT)";
            }
            string str2;

            if (beCompressed)
            {
                str2 = str1 + " (Not yet compressed)";
            }
            else if (flag2)
            {
                TextureFormat textureFormat2 = textureFormat1;
                switch (textureFormat2)
                {
                case TextureFormat.ARGB4444:
                    str2 = str1 + "  Nm 16 bit";
                    break;

                case TextureFormat.ARGB32:
                    str2 = str1 + "  Nm 32 bit";
                    break;

                default:
                    str2 = textureFormat2 == TextureFormat.DXT5 ? str1 + "  DXTnm" : str1 + "  " + TextureUtil.GetTextureFormatString(textureFormat1);
                    break;
                }
            }
            else if (flag1)
            {
                TextureFormat desiredFormat;
                ColorSpace    colorSpace;
                int           compressionQuality;
                atPath.ReadTextureImportInstructions(EditorUserBuildSettings.activeBuildTarget, out desiredFormat, out colorSpace, out compressionQuality);
                str2 = str1 + "\n " + TextureUtil.GetTextureFormatString(textureFormat1) + "(Original) " + TextureUtil.GetTextureFormatString(desiredFormat) + "(Atlas)";
            }
            else
            {
                str2 = str1 + "  " + TextureUtil.GetTextureFormatString(textureFormat1);
            }
            if (flag4)
            {
                str2 = str2 + "\n" + EditorUtility.FormatBytes(TextureUtil.GetStorageMemorySize(target1));
            }
            if (TextureUtil.GetUsageMode(target1) == TextureUsageMode.AlwaysPadded)
            {
                int glWidth  = TextureUtil.GetGLWidth(target1);
                int glHeight = TextureUtil.GetGLHeight(target1);
                if (target1.width != glWidth || target1.height != glHeight)
                {
                    str2 += string.Format("\nPadded to {0}x{1}", (object)glWidth, (object)glHeight);
                }
            }
            return(str2);
        }
コード例 #7
0
        public override string GetInfoString()
        {
            Texture         texture         = this.target as Texture;
            Texture2D       texture2D       = this.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)
            {
                TextureFormat textureFormat2 = textureFormat;
                switch (textureFormat2)
                {
                case TextureFormat.ARGB4444:
                    text += "  Nm 16 bit";
                    goto IL_16B;

                case TextureFormat.RGB24:
                case TextureFormat.RGBA32:
IL_112:
                    if (textureFormat2 != TextureFormat.DXT5)
                    {
                        text = text + "  " + TextureUtil.GetTextureFormatString(textureFormat);
                        goto IL_16B;
                    }
                    text += "  DXTnm";
                    goto IL_16B;

                case TextureFormat.ARGB32:
                    text += "  Nm 32 bit";
                    goto IL_16B;
                }
                goto IL_112;
                IL_16B :;
            }
            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.GetStorageMemorySize(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);
        }