void Summary()
        {
            GUILayout.BeginVertical(EditorStyles.helpBox);

            long totalMemorySize            = 0;
            int  lightmapCount              = 0;
            Dictionary <Vector2, int> sizes = new Dictionary <Vector2, int>();
            bool directionalLightmapsMode   = false;
            bool shadowmaskMode             = false;

            foreach (LightmapData ld in LightmapSettings.lightmaps)
            {
                if (ld.lightmapColor == null)
                {
                    continue;
                }
                lightmapCount++;

                Vector2 texSize = new Vector2(ld.lightmapColor.width, ld.lightmapColor.height);
                if (sizes.ContainsKey(texSize))
                {
                    sizes[texSize]++;
                }
                else
                {
                    sizes.Add(texSize, 1);
                }

                totalMemorySize += TextureUtil.GetStorageMemorySizeLong(ld.lightmapColor);
                if (ld.lightmapDir)
                {
                    totalMemorySize         += TextureUtil.GetStorageMemorySizeLong(ld.lightmapDir);
                    directionalLightmapsMode = true;
                }
                if (ld.shadowMask)
                {
                    totalMemorySize += TextureUtil.GetStorageMemorySizeLong(ld.shadowMask);
                    shadowmaskMode   = true;
                }
            }
            StringBuilder sizesString = new StringBuilder();

            sizesString.Append(lightmapCount);
            sizesString.Append((directionalLightmapsMode ? " Directional" : " Non-Directional"));
            sizesString.Append(" Lightmap");
            if (lightmapCount != 1)
            {
                sizesString.Append("s");
            }
            if (shadowmaskMode)
            {
                sizesString.Append(" with Shadowmask");
                if (lightmapCount != 1)
                {
                    sizesString.Append("s");
                }
            }

            bool first = true;

            foreach (var s in sizes)
            {
                sizesString.Append(first ? ": " : ", ");
                first = false;
                if (s.Value > 1)
                {
                    sizesString.Append(s.Value);
                    sizesString.Append("x");
                }
                sizesString.Append(s.Key.x);
                sizesString.Append("x");
                sizesString.Append(s.Key.y);
                sizesString.Append("px");
            }
            sizesString.Append(" ");

            GUILayout.BeginHorizontal();

            GUILayout.BeginVertical();
            GUILayout.Label(sizesString.ToString(), Styles.LabelStyle);
            GUILayout.EndVertical();

            GUILayout.BeginVertical();
            GUILayout.Label(EditorUtility.FormatBytes(totalMemorySize), Styles.LabelStyle);
            GUILayout.Label((lightmapCount == 0 ? "No Lightmaps" : ""), Styles.LabelStyle);
            GUILayout.EndVertical();

            GUILayout.EndHorizontal();

            if (LightmapEditorSettings.lightmapper != LightmapEditorSettings.Lightmapper.Enlighten)
            {
                GUILayout.BeginVertical();
                GUILayout.Label("Memory Usage: " + Lightmapping.ComputeTotalMemoryUsageInMB().ToString("0.0") + " MB", Styles.LabelStyle);
                GUILayout.Label("Occupied Texels: " + InternalEditorUtility.CountToString(Lightmapping.occupiedTexelCount), Styles.LabelStyle);
                if (Lightmapping.isRunning)
                {
                    int numLightmapsInView             = 0;
                    int numConvergedLightmapsInView    = 0;
                    int numNotConvergedLightmapsInView = 0;

                    int numLightmapsNotInView             = 0;
                    int numConvergedLightmapsNotInView    = 0;
                    int numNotConvergedLightmapsNotInView = 0;

                    int numInvalidConvergenceLightmaps = 0;
                    int numLightmaps = LightmapSettings.lightmaps.Length;
                    for (int i = 0; i < numLightmaps; ++i)
                    {
                        LightmapConvergence lc = Lightmapping.GetLightmapConvergence(i);
                        if (!lc.IsValid())
                        {
                            numInvalidConvergenceLightmaps++;
                            continue;
                        }

                        if (Lightmapping.GetVisibleTexelCount(i) > 0)
                        {
                            numLightmapsInView++;
                            if (lc.IsConverged())
                            {
                                numConvergedLightmapsInView++;
                            }
                            else
                            {
                                numNotConvergedLightmapsInView++;
                            }
                        }
                        else
                        {
                            numLightmapsNotInView++;
                            if (lc.IsConverged())
                            {
                                numConvergedLightmapsNotInView++;
                            }
                            else
                            {
                                numNotConvergedLightmapsNotInView++;
                            }
                        }
                    }
                    EditorGUILayout.LabelField("Lightmaps in view: " + numLightmapsInView, Styles.LabelStyle);
                    EditorGUI.indentLevel += 1;
                    EditorGUILayout.LabelField("Converged: " + numConvergedLightmapsInView, Styles.LabelStyle);
                    EditorGUILayout.LabelField("Not Converged: " + numNotConvergedLightmapsInView, Styles.LabelStyle);
                    EditorGUI.indentLevel -= 1;
                    EditorGUILayout.LabelField("Lightmaps not in view: " + numLightmapsNotInView, Styles.LabelStyle);
                    EditorGUI.indentLevel += 1;
                    EditorGUILayout.LabelField("Converged: " + numConvergedLightmapsNotInView, Styles.LabelStyle);
                    EditorGUILayout.LabelField("Not Converged: " + numNotConvergedLightmapsNotInView, Styles.LabelStyle);
                    EditorGUI.indentLevel -= 1;
                }
                float bakeTime    = Lightmapping.GetLightmapBakeTimeTotal();
                float mraysPerSec = Lightmapping.GetLightmapBakePerformanceTotal();
                if (mraysPerSec >= 0.0)
                {
                    GUILayout.Label("Bake Performance: " + mraysPerSec.ToString("0.00") + " mrays/sec", Styles.LabelStyle);
                }
                if (!Lightmapping.isRunning)
                {
                    float bakeTimeRaw = Lightmapping.GetLightmapBakeTimeRaw();
                    if (bakeTime >= 0.0)
                    {
                        int time  = (int)bakeTime;
                        int timeH = time / 3600;
                        time -= 3600 * timeH;
                        int timeM = time / 60;
                        time -= 60 * timeM;
                        int timeS = time;

                        int timeRaw  = (int)bakeTimeRaw;
                        int timeRawH = timeRaw / 3600;
                        timeRaw -= 3600 * timeRawH;
                        int timeRawM = timeRaw / 60;
                        timeRaw -= 60 * timeRawM;
                        int timeRawS = timeRaw;

                        int oHeadTime  = Math.Max(0, (int)(bakeTime - bakeTimeRaw));
                        int oHeadTimeH = oHeadTime / 3600;
                        oHeadTime -= 3600 * oHeadTimeH;
                        int oHeadTimeM = oHeadTime / 60;
                        oHeadTime -= 60 * oHeadTimeM;
                        int oHeadTimeS = oHeadTime;


                        GUILayout.Label("Total Bake Time: " + timeH.ToString("0") + ":" + timeM.ToString("00") + ":" + timeS.ToString("00"), Styles.LabelStyle);
                        if (Unsupported.IsDeveloperMode())
                        {
                            GUILayout.Label("(Raw Bake Time: " + timeRawH.ToString("0") + ":" + timeRawM.ToString("00") + ":" + timeRawS.ToString("00") + ", Overhead: " + oHeadTimeH.ToString("0") + ":" + oHeadTimeM.ToString("00") + ":" + oHeadTimeS.ToString("00") + ")", Styles.LabelStyle);
                        }
                    }
                }
                GUILayout.EndVertical();
            }

            GUILayout.EndVertical();
        }
Esempio n. 2
0
        private void Summary()
        {
            GUILayout.BeginVertical(EditorStyles.helpBox, new GUILayoutOption[0]);
            long num  = 0L;
            int  num2 = 0;
            Dictionary <Vector2, int> dictionary = new Dictionary <Vector2, int>();
            bool flag  = false;
            bool flag2 = false;

            LightmapData[] lightmaps = LightmapSettings.lightmaps;
            for (int i = 0; i < lightmaps.Length; i++)
            {
                LightmapData lightmapData = lightmaps[i];
                if (!(lightmapData.lightmapColor == null))
                {
                    num2++;
                    Vector2 vector = new Vector2((float)lightmapData.lightmapColor.width, (float)lightmapData.lightmapColor.height);
                    if (dictionary.ContainsKey(vector))
                    {
                        Dictionary <Vector2, int> dictionary2;
                        Vector2 key;
                        (dictionary2 = dictionary)[key = vector] = dictionary2[key] + 1;
                    }
                    else
                    {
                        dictionary.Add(vector, 1);
                    }
                    num += TextureUtil.GetStorageMemorySizeLong(lightmapData.lightmapColor);
                    if (lightmapData.lightmapDir)
                    {
                        num += TextureUtil.GetStorageMemorySizeLong(lightmapData.lightmapDir);
                        flag = true;
                    }
                    if (lightmapData.shadowMask)
                    {
                        num  += TextureUtil.GetStorageMemorySizeLong(lightmapData.shadowMask);
                        flag2 = true;
                    }
                }
            }
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append(num2);
            stringBuilder.Append((!flag) ? " Non-Directional" : " Directional");
            stringBuilder.Append(" Lightmap");
            if (num2 != 1)
            {
                stringBuilder.Append("s");
            }
            if (flag2)
            {
                stringBuilder.Append(" with Shadowmask");
                if (num2 != 1)
                {
                    stringBuilder.Append("s");
                }
            }
            bool flag3 = true;

            foreach (KeyValuePair <Vector2, int> current in dictionary)
            {
                stringBuilder.Append((!flag3) ? ", " : ": ");
                flag3 = false;
                if (current.Value > 1)
                {
                    stringBuilder.Append(current.Value);
                    stringBuilder.Append("x");
                }
                stringBuilder.Append(current.Key.x);
                stringBuilder.Append("x");
                stringBuilder.Append(current.Key.y);
                stringBuilder.Append("px");
            }
            stringBuilder.Append(" ");
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.BeginVertical(new GUILayoutOption[0]);
            GUILayout.Label(stringBuilder.ToString(), 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) ? "" : "No Lightmaps", LightingWindow.Styles.LabelStyle, new GUILayoutOption[0]);
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
            if (LightmapEditorSettings.lightmapper != LightmapEditorSettings.Lightmapper.Radiosity)
            {
                GUILayout.BeginVertical(new GUILayoutOption[0]);
                GUILayout.Label("Memory Usage: " + Lightmapping.ComputeTotalMemoryUsageInMB().ToString("0.0") + " MB", LightingWindow.Styles.LabelStyle, new GUILayoutOption[0]);
                GUILayout.Label("Occupied Texels: " + InternalEditorUtility.CountToString(Lightmapping.occupiedTexelCount), LightingWindow.Styles.LabelStyle, new GUILayoutOption[0]);
                if (Lightmapping.isRunning)
                {
                    int num3  = 0;
                    int num4  = 0;
                    int num5  = 0;
                    int num6  = 0;
                    int num7  = 0;
                    int num8  = 0;
                    int num9  = 0;
                    int num10 = LightmapSettings.lightmaps.Length;
                    for (int j = 0; j < num10; j++)
                    {
                        LightmapConvergence lightmapConvergence = Lightmapping.GetLightmapConvergence(j);
                        if (!lightmapConvergence.IsValid())
                        {
                            num9++;
                        }
                        else if (Lightmapping.GetVisibleTexelCount(j) > 0uL)
                        {
                            num3++;
                            if (lightmapConvergence.IsConverged())
                            {
                                num4++;
                            }
                            else
                            {
                                num5++;
                            }
                        }
                        else
                        {
                            num6++;
                            if (lightmapConvergence.IsConverged())
                            {
                                num7++;
                            }
                            else
                            {
                                num8++;
                            }
                        }
                    }
                    EditorGUILayout.LabelField("Lightmaps in view: " + num3, LightingWindow.Styles.LabelStyle, new GUILayoutOption[0]);
                    EditorGUI.indentLevel++;
                    EditorGUILayout.LabelField("Converged: " + num4, LightingWindow.Styles.LabelStyle, new GUILayoutOption[0]);
                    EditorGUILayout.LabelField("Not Converged: " + num5, LightingWindow.Styles.LabelStyle, new GUILayoutOption[0]);
                    EditorGUI.indentLevel--;
                    EditorGUILayout.LabelField("Lightmaps not in view: " + num6, LightingWindow.Styles.LabelStyle, new GUILayoutOption[0]);
                    EditorGUI.indentLevel++;
                    EditorGUILayout.LabelField("Converged: " + num7, LightingWindow.Styles.LabelStyle, new GUILayoutOption[0]);
                    EditorGUILayout.LabelField("Not Converged: " + num8, LightingWindow.Styles.LabelStyle, new GUILayoutOption[0]);
                    EditorGUI.indentLevel--;
                }
                float lightmapBakeTimeTotal        = Lightmapping.GetLightmapBakeTimeTotal();
                float lightmapBakePerformanceTotal = Lightmapping.GetLightmapBakePerformanceTotal();
                if ((double)lightmapBakePerformanceTotal >= 0.0)
                {
                    GUILayout.Label("Bake Performance: " + lightmapBakePerformanceTotal.ToString("0.00") + " mrays/sec", LightingWindow.Styles.LabelStyle, new GUILayoutOption[0]);
                }
                if (!Lightmapping.isRunning)
                {
                    float lightmapBakeTimeRaw = Lightmapping.GetLightmapBakeTimeRaw();
                    if ((double)lightmapBakeTimeTotal >= 0.0)
                    {
                        int num11 = (int)lightmapBakeTimeTotal;
                        int num12 = num11 / 3600;
                        num11 -= 3600 * num12;
                        int num13 = num11 / 60;
                        num11 -= 60 * num13;
                        int num14 = num11;
                        int num15 = (int)lightmapBakeTimeRaw;
                        int num16 = num15 / 3600;
                        num15 -= 3600 * num16;
                        int num17 = num15 / 60;
                        num15 -= 60 * num17;
                        int num18 = num15;
                        int num19 = Math.Max(0, (int)(lightmapBakeTimeTotal - lightmapBakeTimeRaw));
                        int num20 = num19 / 3600;
                        num19 -= 3600 * num20;
                        int num21 = num19 / 60;
                        num19 -= 60 * num21;
                        int num22 = num19;
                        GUILayout.Label(string.Concat(new string[]
                        {
                            "Total Bake Time: ",
                            num12.ToString("0"),
                            ":",
                            num13.ToString("00"),
                            ":",
                            num14.ToString("00")
                        }), LightingWindow.Styles.LabelStyle, new GUILayoutOption[0]);
                        if (Unsupported.IsDeveloperMode())
                        {
                            GUILayout.Label(string.Concat(new string[]
                            {
                                "(Raw Bake Time: ",
                                num16.ToString("0"),
                                ":",
                                num17.ToString("00"),
                                ":",
                                num18.ToString("00"),
                                ", Overhead: ",
                                num20.ToString("0"),
                                ":",
                                num21.ToString("00"),
                                ":",
                                num22.ToString("00"),
                                ")"
                            }), LightingWindow.Styles.LabelStyle, new GUILayoutOption[0]);
                        }
                    }
                }
                GUILayout.EndVertical();
            }
            GUILayout.EndVertical();
        }