public bool EditRenderers() { GameObject[] array; Renderer[] selectedObjectsOfType = SceneModeUtility.GetSelectedObjectsOfType <Renderer>(out array, new Type[] { typeof(MeshRenderer), typeof(SkinnedMeshRenderer) }); if (array.Length == 0) { return(false); } EditorGUILayout.InspectorTitlebar(selectedObjectsOfType); SerializedObject serializedObject = new SerializedObject(array); EditorGUI.BeginDisabledGroup(!SceneModeUtility.StaticFlagField("Lightmap Static", serializedObject.FindProperty("m_StaticEditorFlags"), 1)); SerializedObject serializedObject2 = new SerializedObject(selectedObjectsOfType); float num = LightmapVisualization.GetLightmapLODLevelScale(selectedObjectsOfType[0]); for (int i = 1; i < selectedObjectsOfType.Length; i++) { if (!Mathf.Approximately(num, LightmapVisualization.GetLightmapLODLevelScale(selectedObjectsOfType[i]))) { num = 1f; } } float lightmapScale = this.LightmapScaleGUI(serializedObject2, num) * LightmapVisualization.GetLightmapLODLevelScale(selectedObjectsOfType[0]); float cachedSurfaceArea = (!(selectedObjectsOfType[0] is MeshRenderer)) ? InternalMeshUtil.GetCachedSkinnedMeshSurfaceArea(selectedObjectsOfType[0] as SkinnedMeshRenderer) : InternalMeshUtil.GetCachedMeshSurfaceArea(selectedObjectsOfType[0] as MeshRenderer); this.ShowClampedSizeInLightmapGUI(lightmapScale, cachedSurfaceArea); this.RendererUVSettings(serializedObject2); LightingWindowObjectTab.LightmapParametersGUI(serializedObject2.FindProperty("m_LightmapParameters"), LightingWindowObjectTab.s_Styles.LightmapParameters); this.m_ShowBakedLM = EditorGUILayout.Foldout(this.m_ShowBakedLM, LightingWindowObjectTab.s_Styles.Atlas); if (this.m_ShowBakedLM) { this.ShowAtlasGUI(serializedObject2); } this.m_ShowRealtimeLM = EditorGUILayout.Foldout(this.m_ShowRealtimeLM, LightingWindowObjectTab.s_Styles.RealtimeLM); if (this.m_ShowRealtimeLM) { this.ShowRealtimeLMGUI(serializedObject2, selectedObjectsOfType[0]); } if (LightmapEditorSettings.HasZeroAreaMesh(selectedObjectsOfType[0])) { EditorGUILayout.HelpBox(LightingWindowObjectTab.s_Styles.ZeroAreaPackingMesh.text, MessageType.Warning); } if (LightmapEditorSettings.HasClampedResolution(selectedObjectsOfType[0])) { EditorGUILayout.HelpBox(LightingWindowObjectTab.s_Styles.ClampedPackingResolution.text, MessageType.Warning); } if (!LightingWindowObjectTab.HasNormals(selectedObjectsOfType[0])) { EditorGUILayout.HelpBox(LightingWindowObjectTab.s_Styles.NoNormalsNoLightmapping.text, MessageType.Warning); } serializedObject.ApplyModifiedProperties(); serializedObject2.ApplyModifiedProperties(); EditorGUI.EndDisabledGroup(); GUILayout.Space(10f); return(true); }
private void GeneralSettingsGUI(SerializedObject so, SerializedProperty enableRealtimeGI, SerializedProperty enableBakedGI) { this.m_ShowGeneralSettings = EditorGUILayout.FoldoutTitlebar(this.m_ShowGeneralSettings, LightingWindow.styles.GeneralGILabel); if (!this.m_ShowGeneralSettings) { return; } SerializedProperty property = so.FindProperty("m_GISettings.m_AlbedoBoost"); SerializedProperty property2 = so.FindProperty("m_GISettings.m_IndirectOutputScale"); SerializedProperty property3 = so.FindProperty("m_LightmapEditorSettings.m_TextureWidth"); SerializedProperty prop = so.FindProperty("m_LightmapEditorSettings.m_LightmapParameters"); SerializedProperty serializedProperty = so.FindProperty("m_LightmapsMode"); bool flag = enableBakedGI.boolValue || enableRealtimeGI.boolValue; EditorGUI.BeginDisabledGroup(!flag); EditorGUI.indentLevel++; EditorGUILayout.IntPopup(serializedProperty, this.kModeStrings, this.kModeValues, LightingWindow.s_Styles.DirectionalMode, new GUILayoutOption[0]); if (serializedProperty.intValue == 2) { EditorGUILayout.HelpBox(LightingWindow.s_Styles.NoDirectionalSpecularInSM2AndGLES2.text, MessageType.Warning); } EditorGUILayout.Slider(property2, 0f, 5f, LightingWindow.styles.IndirectOutputScale, new GUILayoutOption[0]); EditorGUILayout.Slider(property, 1f, 10f, LightingWindow.styles.AlbedoBoost, new GUILayoutOption[0]); if (LightingWindowObjectTab.LightmapParametersGUI(prop, LightingWindow.styles.DefaultLightmapParameters)) { this.m_Mode = LightingWindow.Mode.ObjectSettings; } EditorGUILayout.IntPopup(property3, this.kMaxAtlasSizeStrings, this.kMaxAtlasSizeValues, LightingWindow.styles.MaxAtlasSize, new GUILayoutOption[0]); this.DeveloperBuildEnlightenSettings(so); EditorGUI.EndDisabledGroup(); EditorGUI.indentLevel--; }
private void OnEnable() { base.titleContent = base.GetLocalizedTitleContent(); this.m_LightingTab = new LightingWindowLightingTab(); this.m_LightingTab.OnEnable(); this.m_LightmapPreviewTab = new LightingWindowLightmapPreviewTab(); this.m_ObjectTab = new LightingWindowObjectTab(); this.m_ObjectTab.OnEnable(this); base.autoRepaintOnSceneChange = false; this.m_PreviewResizer.Init("LightmappingPreview"); EditorApplication.searchChanged = (EditorApplication.CallbackFunction)Delegate.Combine(EditorApplication.searchChanged, new EditorApplication.CallbackFunction(base.Repaint)); base.Repaint(); }
private void OnEnable() { this.m_LightmapPreviewTab = new LightingWindowLightmapPreviewTab(); this.m_ObjectTab = new LightingWindowObjectTab(); this.m_ObjectTab.OnEnable(this); this.m_ShowRealtimeSettings = InspectorState.GetBool("ShowRealtimeLightingSettings", true); this.m_ShowBakeSettings = InspectorState.GetBool("ShowBakedLightingSettings", true); this.m_ShowGeneralSettings = InspectorState.GetBool("ShowGeneralLightingSettings", true); this.UpdateAnimatedBools(true); base.autoRepaintOnSceneChange = true; this.m_PreviewResizer.Init("LightmappingPreview"); EditorApplication.searchChanged = (EditorApplication.CallbackFunction)Delegate.Combine(EditorApplication.searchChanged, new EditorApplication.CallbackFunction(base.Repaint)); base.Repaint(); }
private void OnEnable() { this.titleContent = this.GetLocalizedTitleContent(); this.m_LightmapPreviewTab = new LightingWindowLightmapPreviewTab(); this.m_ObjectTab = new LightingWindowObjectTab(); this.m_ObjectTab.OnEnable((EditorWindow)this); this.m_ShowRealtimeSettings = SessionState.GetBool("ShowRealtimeLightingSettings", true); this.m_ShowBakeSettings = SessionState.GetBool("ShowBakedLightingSettings", true); this.m_ShowGeneralSettings = SessionState.GetBool("ShowGeneralLightingSettings", true); this.UpdateAnimatedBools(true); this.autoRepaintOnSceneChange = true; this.m_PreviewResizer.Init("LightmappingPreview"); EditorApplication.searchChanged += new EditorApplication.CallbackFunction(((EditorWindow)this).Repaint); this.Repaint(); }
public bool EditTerrains() { GameObject[] array; Terrain[] selectedObjectsOfType = SceneModeUtility.GetSelectedObjectsOfType <Terrain>(out array, new Type[0]); bool result; if (array.Length == 0) { result = false; } else { EditorGUILayout.InspectorTitlebar(selectedObjectsOfType); SerializedObject serializedObject = new SerializedObject(array); using (new EditorGUI.DisabledScope(!SceneModeUtility.StaticFlagField("Lightmap Static", serializedObject.FindProperty("m_StaticEditorFlags"), 1))) { if (GUI.enabled) { this.ShowTerrainChunks(selectedObjectsOfType); } SerializedObject serializedObject2 = new SerializedObject(selectedObjectsOfType.ToArray <Terrain>()); float lightmapScale = this.LightmapScaleGUI(serializedObject2, 1f); TerrainData terrainData = selectedObjectsOfType[0].terrainData; float cachedSurfaceArea = (!(terrainData != null)) ? 0f : (terrainData.size.x * terrainData.size.z); this.ShowClampedSizeInLightmapGUI(lightmapScale, cachedSurfaceArea); LightingWindowObjectTab.LightmapParametersGUI(serializedObject2.FindProperty("m_LightmapParameters"), LightingWindowObjectTab.s_Styles.LightmapParameters, true); if (GUI.enabled && selectedObjectsOfType.Length == 1 && selectedObjectsOfType[0].terrainData != null) { this.ShowBakePerformanceWarning(serializedObject2, selectedObjectsOfType[0]); } this.m_ShowBakedLM = EditorGUILayout.Foldout(this.m_ShowBakedLM, LightingWindowObjectTab.s_Styles.Atlas); if (this.m_ShowBakedLM) { this.ShowAtlasGUI(serializedObject2); } this.m_ShowRealtimeLM = EditorGUILayout.Foldout(this.m_ShowRealtimeLM, LightingWindowObjectTab.s_Styles.RealtimeLM); if (this.m_ShowRealtimeLM) { this.ShowRealtimeLMGUI(selectedObjectsOfType[0]); } serializedObject.ApplyModifiedProperties(); serializedObject2.ApplyModifiedProperties(); } GUILayout.Space(10f); result = true; } return(result); }
public static bool LightmapParametersGUI(SerializedProperty prop, GUIContent content, bool advancedParameters) { EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]); if (advancedParameters) { EditorGUIInternal.AssetPopup <LightmapParameters>(prop, content, "giparams", "Default scene parameter"); } else { EditorGUIInternal.AssetPopup <LightmapParameters>(prop, content, "giparams", "Default-Medium"); } string text = "Edit..."; if (LightingWindowObjectTab.isBuiltIn(prop)) { text = "View"; } bool result = false; if (prop.objectReferenceValue == null) { SerializedObject serializedObject = new SerializedObject(LightmapEditorSettings.GetLightmapSettings()); SerializedProperty serializedProperty = serializedObject.FindProperty("m_LightmapEditorSettings.m_LightmapParameters"); using (new EditorGUI.DisabledScope(serializedProperty == null)) { if (GUILayout.Button(text, EditorStyles.miniButton, new GUILayoutOption[] { GUILayout.ExpandWidth(false) })) { Selection.activeObject = serializedProperty.objectReferenceValue; result = true; } } } else if (GUILayout.Button(text, EditorStyles.miniButton, new GUILayoutOption[] { GUILayout.ExpandWidth(false) })) { Selection.activeObject = prop.objectReferenceValue; result = true; } EditorGUILayout.EndHorizontal(); return(result); }
void OnEnable() { titleContent = GetLocalizedTitleContent(); m_LightingTab = new LightingWindowLightingTab(); m_LightingTab.OnEnable(); m_LightmapPreviewTab = new LightingWindowLightmapPreviewTab(); m_ObjectTab = new LightingWindowObjectTab(); m_ObjectTab.OnEnable(this); InitLightmapSettings(); autoRepaintOnSceneChange = false; m_PreviewResizer.Init("LightmappingPreview"); EditorApplication.searchChanged += Repaint; Repaint(); }
public bool EditTerrains() { GameObject[] gameObjects; Terrain[] selectedObjectsOfType = SceneModeUtility.GetSelectedObjectsOfType <Terrain>(out gameObjects); if (gameObjects.Length == 0) { return(false); } EditorGUILayout.InspectorTitlebar((UnityEngine.Object[])selectedObjectsOfType); SerializedObject serializedObject = new SerializedObject((UnityEngine.Object[])gameObjects); EditorGUI.BeginDisabledGroup(!SceneModeUtility.StaticFlagField("Lightmap Static", serializedObject.FindProperty("m_StaticEditorFlags"), 1)); if (GUI.enabled) { this.ShowTerrainChunks(selectedObjectsOfType); } SerializedObject so = new SerializedObject((UnityEngine.Object[])((IEnumerable <Terrain>)selectedObjectsOfType).ToArray <Terrain>()); float lightmapScale = this.LightmapScaleGUI(so, 1f); TerrainData terrainData = selectedObjectsOfType[0].terrainData; float cachedSurfaceArea = !((UnityEngine.Object)terrainData != (UnityEngine.Object)null) ? 0.0f : terrainData.size.x * terrainData.size.z; this.ShowClampedSizeInLightmapGUI(lightmapScale, cachedSurfaceArea); LightingWindowObjectTab.LightmapParametersGUI(so.FindProperty("m_LightmapParameters"), LightingWindowObjectTab.s_Styles.LightmapParameters); if (GUI.enabled && selectedObjectsOfType.Length == 1 && (UnityEngine.Object)selectedObjectsOfType[0].terrainData != (UnityEngine.Object)null) { this.ShowBakePerformanceWarning(so, selectedObjectsOfType[0]); } this.m_ShowBakedLM = EditorGUILayout.Foldout(this.m_ShowBakedLM, LightingWindowObjectTab.s_Styles.Atlas); if (this.m_ShowBakedLM) { this.ShowAtlasGUI(so); } this.m_ShowRealtimeLM = EditorGUILayout.Foldout(this.m_ShowRealtimeLM, LightingWindowObjectTab.s_Styles.RealtimeLM); if (this.m_ShowRealtimeLM) { this.ShowRealtimeLMGUI(selectedObjectsOfType[0]); } serializedObject.ApplyModifiedProperties(); so.ApplyModifiedProperties(); EditorGUI.EndDisabledGroup(); GUILayout.Space(10f); return(true); }
private void GeneralSettingsGUI(SerializedObject so, bool enableRealtimeGI, bool enableBakedGI) { this.m_ShowGeneralSettings = EditorGUILayout.FoldoutTitlebar(this.m_ShowGeneralSettings, LightingWindow.styles.GeneralGILabel); if (this.m_ShowGeneralSettings) { SerializedProperty serializedProperty = so.FindProperty("m_GISettings.m_AlbedoBoost"); SerializedProperty property = so.FindProperty("m_GISettings.m_IndirectOutputScale"); SerializedProperty prop = so.FindProperty("m_LightmapEditorSettings.m_LightmapParameters"); SerializedProperty serializedProperty2 = so.FindProperty("m_LightmapEditorSettings.m_LightmapsBakeMode"); bool flag = enableBakedGI || enableRealtimeGI; EditorGUI.indentLevel++; using (new EditorGUI.DisabledScope(!flag)) { EditorGUILayout.IntPopup(serializedProperty2, this.kModeStrings, this.kModeValues, LightingWindow.s_Styles.DirectionalMode, new GUILayoutOption[0]); if (serializedProperty2.intValue == 1) { EditorGUILayout.HelpBox(LightingWindow.s_Styles.NoDirectionalInSM2AndGLES2.text, MessageType.Warning); } if (serializedProperty2.intValue == 2) { EditorGUILayout.HelpBox(LightingWindow.s_Styles.NoDirectionalSpecularInSM2AndGLES2.text, MessageType.Warning); } EditorGUILayout.Slider(property, 0f, 5f, LightingWindow.styles.IndirectOutputScale, new GUILayoutOption[0]); EditorGUI.BeginChangeCheck(); EditorGUILayout.Slider(serializedProperty, 1f, 10f, LightingWindow.styles.AlbedoBoost, new GUILayoutOption[0]); if (EditorGUI.EndChangeCheck()) { Lightmapping.bounceBoost = serializedProperty.floatValue; } if (LightingWindowObjectTab.LightmapParametersGUI(prop, LightingWindow.styles.DefaultLightmapParameters, false)) { this.m_Mode = LightingWindow.Mode.ObjectSettings; } this.DeveloperBuildEnlightenSettings(so); } EditorGUI.indentLevel--; } }
private void OnEnable() { this.m_LightmapPreviewTab = new LightingWindowLightmapPreviewTab(); this.m_ObjectTab = new LightingWindowObjectTab(); this.m_ObjectTab.OnEnable(this); this.m_ShowRealtimeSettings = InspectorState.GetBool("ShowRealtimeLightingSettings", true); this.m_ShowBakeSettings = InspectorState.GetBool("ShowBakedLightingSettings", true); this.m_ShowGeneralSettings = InspectorState.GetBool("ShowGeneralLightingSettings", true); this.UpdateAnimatedBools(true); base.autoRepaintOnSceneChange = true; this.m_PreviewResizer.Init("LightmappingPreview"); EditorApplication.searchChanged = (EditorApplication.CallbackFunction)Delegate.Combine(EditorApplication.searchChanged, new EditorApplication.CallbackFunction(base.Repaint)); base.Repaint(); }