private void LightmapRow(int index, LightmapData[] lightmaps, bool showDirLightmap, bool showShadowMask, LightingWindowLightmapPreviewTab.GlobalMapsViewType viewType) { int num = (viewType != LightingWindowLightmapPreviewTab.GlobalMapsViewType.Performance) ? 7 : 5; float size = (float)(2 * EditorStyles.miniLabel.margin.top + (num - 1) * Mathf.Max(EditorStyles.miniLabel.margin.top, EditorStyles.miniLabel.margin.bottom) + 2 * EditorStyles.miniLabel.padding.top + (num - 1) * EditorStyles.miniLabel.padding.vertical) + (float)(num - 1) * EditorStyles.miniLabel.lineHeight + (float)EditorStyles.miniLabel.font.fontSize; GUILayout.Space(5f); GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.Space(20f); lightmaps[index].lightmapColor = this.LightmapField(lightmaps[index].lightmapColor, index, size); if (showDirLightmap) { GUILayout.Space(5f); lightmaps[index].lightmapDir = this.LightmapField(lightmaps[index].lightmapDir, index, size); } if (showShadowMask) { GUILayout.Space(5f); lightmaps[index].shadowMask = this.LightmapField(lightmaps[index].shadowMask, index, size); } GUILayout.Space(5f); if (viewType == LightingWindowLightmapPreviewTab.GlobalMapsViewType.Performance) { this.LightmapPerformanceStats(index); } else { this.LightmapMemoryStats(index); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); }
private void MemoryCentricView(LightmapData[] lightmaps, bool showDirLightmap, bool showShadowMask, LightingWindowLightmapPreviewTab.GlobalMapsViewType viewType) { Lightmapping.ResetExplicitlyShownMemLabels(); Dictionary <Hash128, SortedList <int, int> > dictionary = new Dictionary <Hash128, SortedList <int, int> >(); for (int i = 0; i < lightmaps.Length; i++) { Hash128 key; if (Lightmapping.GetGBufferHash(i, out key)) { if (!dictionary.ContainsKey(key)) { dictionary.Add(key, new SortedList <int, int>()); } dictionary[key].Add(i, i); } } float num = 0f; float num2 = 0f; float num3 = 0f; foreach (KeyValuePair <Hash128, SortedList <int, int> > current in dictionary) { Hash128 key2 = current.Key; float gBufferMemory = Lightmapping.GetGBufferMemory(ref key2); num += gBufferMemory; SortedList <int, int> value = current.Value; foreach (KeyValuePair <int, int> current2 in value) { LightmapMemory lightmapMemory = Lightmapping.GetLightmapMemory(current2.Value); num2 += lightmapMemory.lightmapDataSize; num2 += lightmapMemory.lightmapTexturesSize; num3 += lightmapMemory.albedoDataSize; num3 += lightmapMemory.albedoTextureSize; num3 += lightmapMemory.emissiveDataSize; num3 += lightmapMemory.emissiveTextureSize; } } if (dictionary.Count > 0) { string content = string.Format("G-buffers ({0}) | Lightmaps ({1}) | Albedo/Emissive ({2})", this.SizeString(num), this.SizeString(num2), this.SizeString(num3)); bool @bool = EditorPrefs.GetBool("LightingWindowGlobalMapsGLAE", true); bool flag = EditorGUILayout.Foldout(@bool, content, true, LightingWindowLightmapPreviewTab.s_Styles.boldFoldout); if (flag != @bool) { EditorPrefs.SetBool("LightingWindowGlobalMapsGLAE", flag); } if (flag) { foreach (KeyValuePair <Hash128, SortedList <int, int> > current3 in dictionary) { GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.Space(15f); GUILayout.BeginVertical(new GUILayoutOption[0]); Hash128 key3 = current3.Key; GUILayout.Label(EditorGUIUtility.TrTextContent("G-buffer: " + Lightmapping.GetGBufferMemory(ref key3).ToString("0.0") + " MB", key3.ToString(), null), EditorStyles.miniLabel, new GUILayoutOption[] { GUILayout.ExpandWidth(false) }); SortedList <int, int> value2 = current3.Value; foreach (KeyValuePair <int, int> current4 in value2) { this.LightmapRow(current4.Value, lightmaps, showDirLightmap, showShadowMask, viewType); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.Space(10f); } } } ulong[] counts = new ulong[0]; string[] objectNames; float[] sizes; Lightmapping.GetTransmissionTexturesMemLabels(out objectNames, out sizes); this.ShowObjectNamesSizesAndCounts("Transmission textures", "LightingWindowGlobalMapsTT", objectNames, sizes, counts, LightingWindowLightmapPreviewTab.Precision.Tenths); string[] objectNames2; float[] sizes2; ulong[] counts2; Lightmapping.GetGeometryMemory(out objectNames2, out sizes2, out counts2); this.ShowObjectNamesSizesAndCounts("Geometry data", "LightingWindowGlobalMapsGD", objectNames2, sizes2, counts2, LightingWindowLightmapPreviewTab.Precision.Hundredths); string[] objectNames3; float[] sizes3; Lightmapping.GetNotShownMemLabels(out objectNames3, out sizes3); string foldoutName = (!Lightmapping.isProgressiveLightmapperDone) ? "In-flight" : "Leaks"; this.ShowObjectNamesSizesAndCounts(foldoutName, "LightingWindowGlobalMapsIF", objectNames3, sizes3, counts, LightingWindowLightmapPreviewTab.Precision.Tenths); }
private void PerformanceCentricView(LightmapData[] lightmaps, bool showDirLightmap, bool showShadowMask, LightingWindowLightmapPreviewTab.GlobalMapsViewType viewType) { for (int i = 0; i < lightmaps.Length; i++) { this.LightmapRow(i, lightmaps, showDirLightmap, showShadowMask, viewType); } }
public void Maps() { if (LightingWindowLightmapPreviewTab.s_Styles == null) { LightingWindowLightmapPreviewTab.s_Styles = new LightingWindowLightmapPreviewTab.Styles(); } GUI.changed = false; if (Lightmapping.giWorkflowMode == Lightmapping.GIWorkflowMode.OnDemand) { SerializedObject serializedObject = new SerializedObject(LightmapEditorSettings.GetLightmapSettings()); SerializedProperty property = serializedObject.FindProperty("m_LightingDataAsset"); EditorGUILayout.PropertyField(property, LightingWindowLightmapPreviewTab.s_Styles.LightingDataAsset, new GUILayoutOption[0]); serializedObject.ApplyModifiedProperties(); } GUILayout.Space(10f); LightingWindowLightmapPreviewTab.GlobalMapsViewType globalMapsViewType = LightingWindowLightmapPreviewTab.GlobalMapsViewType.Performance; if (EditorPrefs.GetBool("DeveloperMode", false)) { GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.FlexibleSpace(); globalMapsViewType = (LightingWindowLightmapPreviewTab.GlobalMapsViewType)EditorPrefs.GetInt("LightingWindowGlobalMapsViewType", (int)globalMapsViewType); EditorGUI.BeginChangeCheck(); globalMapsViewType = (LightingWindowLightmapPreviewTab.GlobalMapsViewType)GUILayout.Toolbar((int)globalMapsViewType, new string[] { "Performance", "Memory" }, EditorStyles.miniButton, new GUILayoutOption[] { GUILayout.ExpandWidth(false) }); if (EditorGUI.EndChangeCheck()) { EditorPrefs.SetInt("LightingWindowGlobalMapsViewType", (int)globalMapsViewType); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } LightmapData[] lightmaps = LightmapSettings.lightmaps; this.m_ScrollPositionMaps = GUILayout.BeginScrollView(this.m_ScrollPositionMaps, new GUILayoutOption[0]); bool showDirLightmap = false; bool showShadowMask = false; LightmapData[] array = lightmaps; for (int i = 0; i < array.Length; i++) { LightmapData lightmapData = array[i]; if (lightmapData.lightmapDir != null) { showDirLightmap = true; } if (lightmapData.shadowMask != null) { showShadowMask = true; } } if (globalMapsViewType == LightingWindowLightmapPreviewTab.GlobalMapsViewType.Performance) { this.PerformanceCentricView(lightmaps, showDirLightmap, showShadowMask, globalMapsViewType); } else { this.MemoryCentricView(lightmaps, showDirLightmap, showShadowMask, globalMapsViewType); } GUILayout.EndScrollView(); }