public void RenderSettings(bool showLightmapSettings, bool showshadowBias) { if (m_SerializedObject == null || m_GameObjectsSerializedObject == null || m_GameObjectsSerializedObject.targetObjectsCount == 0) { return; } m_GameObjectsSerializedObject.Update(); m_LightmapSettings.Update(); ReceiveGI receiveGI = (ReceiveGI)m_ReceiveGI.intValue; bool contributeGI = (m_StaticEditorFlags.intValue & (int)StaticEditorFlags.ContributeGI) != 0; bool showEnlightenSettings = isPrefabAsset || m_EnabledRealtimeGI.boolValue || (m_EnabledBakedGI.boolValue && LightmapEditorSettings.lightmapper == LightmapEditorSettings.Lightmapper.Enlighten); // m_ReceiveGI might still be set to Lightmaps, but LightProbes is shown in the inspector since the contributeGI if off. // In this case we still have to mark it as "multiple values" even though both have "Lightmaps" as the value, but one is showing a grayed out "Light Probes" in the UI bool showMixedGIValue = m_ReceiveGI.hasMultipleDifferentValues || ((m_StaticEditorFlags.hasMultipleDifferentValuesBitwise & (int)StaticEditorFlags.ContributeGI) != 0); m_ShowLightingSettings.value = EditorGUILayout.BeginFoldoutHeaderGroup(m_ShowLightingSettings.value, Styles.LightingSettings); if (m_ShowLightingSettings.value) { EditorGUI.indentLevel += 1; EditorGUILayout.PropertyField(m_CastShadows, Styles.CastShadows, true); bool isDeferredRenderingPath = SceneView.IsUsingDeferredRenderingPath(); if (SupportedRenderingFeatures.active.receiveShadows) { using (new EditorGUI.DisabledScope(isDeferredRenderingPath)) EditorGUILayout.PropertyField(m_ReceiveShadows, Styles.ReceiveShadows, true); } if (!showLightmapSettings) { EditorGUI.indentLevel -= 1; EditorGUILayout.EndFoldoutHeaderGroup(); return; } contributeGI = ContributeGISettings(); if (!(m_EnabledBakedGI.boolValue || m_EnabledRealtimeGI.boolValue) && !isPrefabAsset && contributeGI) { EditorGUILayout.HelpBox(Styles.GINotEnabledInfo.text, MessageType.Info); EditorGUI.indentLevel -= 1; EditorGUILayout.EndFoldoutHeaderGroup(); return; } if (contributeGI) { EditorGUI.BeginChangeCheck(); EditorGUI.showMixedValue = showMixedGIValue; receiveGI = (ReceiveGI)EditorGUILayout.IntPopup(Styles.ReceiveGITitle, (int)receiveGI, Styles.ReceiveGILightmapStrings, Styles.ReceiveGILightmapValues); EditorGUI.showMixedValue = false; if (EditorGUI.EndChangeCheck()) { m_ReceiveGI.intValue = (int)receiveGI; } if (showEnlightenSettings) { EditorGUILayout.PropertyField(m_ImportantGI, Styles.ImportantGI); } if (receiveGI == ReceiveGI.LightProbes && !showMixedGIValue) { LightmapScaleGUI(true, Styles.AlbedoScale, true); } } else { using (new EditorGUI.DisabledScope(true)) { EditorGUI.showMixedValue = showMixedGIValue; receiveGI = (ReceiveGI)EditorGUILayout.IntPopup(Styles.ReceiveGITitle, (int)ReceiveGI.LightProbes, Styles.ReceiveGILightmapStrings, Styles.ReceiveGILightmapValues); EditorGUI.showMixedValue = false; } } EditorGUI.indentLevel -= 1; } EditorGUILayout.EndFoldoutHeaderGroup(); if (showLightmapSettings && contributeGI && receiveGI == ReceiveGI.Lightmaps && !showMixedGIValue) { m_ShowLightmapSettings.value = EditorGUILayout.BeginFoldoutHeaderGroup(m_ShowLightmapSettings.value, Styles.LightmapSettings); if (m_ShowLightmapSettings.value) { EditorGUI.indentLevel += 1; bool showProgressiveSettings = isPrefabAsset || (m_EnabledBakedGI.boolValue && LightmapEditorSettings.lightmapper != LightmapEditorSettings.Lightmapper.Enlighten); LightmapScaleGUI(true, Styles.ScaleInLightmap, false); if (showProgressiveSettings) { EditorGUILayout.PropertyField(m_StitchLightmapSeams, Styles.StitchLightmapSeams); } LightmapParametersGUI(m_LightmapParameters, Styles.LightmapParameters); if (showEnlightenSettings) { RendererUVSettings(); } ShowAtlasGUI(m_Renderers[0].GetInstanceID()); ShowRealtimeLMGUI(m_Renderers[0]); if (LightmapEditorSettings.HasZeroAreaMesh(m_Renderers[0])) { EditorGUILayout.HelpBox(Styles.ZeroAreaPackingMesh.text, MessageType.Warning); } DisplayMeshWarning(); if (showEnlightenSettings) { if (LightmapEditorSettings.HasClampedResolution(m_Renderers[0])) { EditorGUILayout.HelpBox(Styles.ClampedPackingResolution.text, MessageType.Warning); } } if (showProgressiveSettings) { if (LightmapEditorSettings.HasUVOverlaps(m_Renderers[0])) { EditorGUILayout.HelpBox(Styles.UVOverlap.text, MessageType.Warning); } } EditorGUI.indentLevel -= 1; } EditorGUILayout.EndFoldoutHeaderGroup(); } }
public void RenderMeshSettings(bool showLightmapSettings) { if (s_Styles == null) { s_Styles = new Styles(); } if (m_SerializedObject == null || m_GameObjectsSerializedObject == null || m_GameObjectsSerializedObject.targetObjects.Length == 0) { return; } m_GameObjectsSerializedObject.Update(); m_LightmapSettings.Update(); EditorGUILayout.PropertyField(m_CastShadows, s_Styles.CastShadows, true); bool isDeferredRenderingPath = SceneView.IsUsingDeferredRenderingPath(); if (SupportedRenderingFeatures.active.rendererSupportsReceiveShadows) { using (new EditorGUI.DisabledScope(isDeferredRenderingPath)) EditorGUILayout.PropertyField(m_ReceiveShadows, s_Styles.ReceiveShadows, true); } if (SupportedRenderingFeatures.active.rendererSupportsMotionVectors) { EditorGUILayout.PropertyField(m_MotionVectors, s_Styles.MotionVectors, true); } if (!showLightmapSettings) { return; } LightmapStaticSettings(); if (!(m_EnabledBakedGI.boolValue || m_EnabledRealtimeGI.boolValue) && !isPrefabAsset) { EditorGUILayout.HelpBox(s_Styles.GINotEnabledInfo.text, MessageType.Info); return; } bool enableSettings = (m_StaticEditorFlags.intValue & (int)StaticEditorFlags.LightmapStatic) != 0; // We want to show the lightmap settings if the lightmap static flag is set. // Most of the settings apply to both, realtime and baked GI. if (enableSettings) { bool showEnlightenSettings = isPrefabAsset || m_EnabledRealtimeGI.boolValue || (m_EnabledBakedGI.boolValue && LightmapEditorSettings.lightmapper == LightmapEditorSettings.Lightmapper.Enlighten); bool showProgressiveSettings = isPrefabAsset || (m_EnabledBakedGI.boolValue && LightmapEditorSettings.lightmapper != LightmapEditorSettings.Lightmapper.Enlighten); if (showEnlightenSettings) { m_ShowChartingSettings = EditorGUILayout.Foldout(m_ShowChartingSettings, s_Styles.UVCharting, true); if (m_ShowChartingSettings) { RendererUVSettings(); } } m_ShowLightmapSettings = EditorGUILayout.Foldout(m_ShowLightmapSettings, s_Styles.LightmapSettings, true); if (m_ShowLightmapSettings) { EditorGUI.indentLevel += 1; float lodScale = LightmapVisualization.GetLightmapLODLevelScale(m_Renderers[0]); for (int i = 1; i < m_Renderers.Length; i++) { if (!Mathf.Approximately(lodScale, LightmapVisualization.GetLightmapLODLevelScale(m_Renderers[i]))) { lodScale = 1.0F; } } float lightmapScale = LightmapScaleGUI(lodScale) * LightmapVisualization.GetLightmapLODLevelScale(m_Renderers[0]); // tell the user if the object's size in lightmap has reached the max atlas size float cachedSurfaceArea = InternalMeshUtil.GetCachedMeshSurfaceArea((MeshRenderer)m_Renderers[0]); ShowClampedSizeInLightmapGUI(lightmapScale, cachedSurfaceArea); // Enlighten specific if (showEnlightenSettings) { EditorGUILayout.PropertyField(m_ImportantGI, s_Styles.ImportantGI); } if (showProgressiveSettings) { EditorGUILayout.PropertyField(m_StitchLightmapSeams, s_Styles.StitchLightmapSeams); } LightmapParametersGUI(m_LightmapParameters, s_Styles.LightmapParameters); m_ShowBakedLM = EditorGUILayout.Foldout(m_ShowBakedLM, s_Styles.Atlas, true); if (m_ShowBakedLM) { ShowAtlasGUI(m_Renderers[0].GetInstanceID()); } m_ShowRealtimeLM = EditorGUILayout.Foldout(m_ShowRealtimeLM, s_Styles.RealtimeLM, true); if (m_ShowRealtimeLM) { ShowRealtimeLMGUI(m_Renderers[0]); } EditorGUI.indentLevel -= 1; } if (LightmapEditorSettings.HasZeroAreaMesh(m_Renderers[0])) { EditorGUILayout.HelpBox(s_Styles.ZeroAreaPackingMesh.text, MessageType.Warning); } if (LightmapEditorSettings.HasClampedResolution(m_Renderers[0])) { EditorGUILayout.HelpBox(s_Styles.ClampedPackingResolution.text, MessageType.Warning); } if (!HasNormals(m_Renderers[0])) { EditorGUILayout.HelpBox(s_Styles.NoNormalsNoLightmapping.text, MessageType.Warning); } if (LightmapEditorSettings.HasUVOverlaps(m_Renderers[0])) { EditorGUILayout.HelpBox(s_Styles.UVOverlap.text, MessageType.Warning); } m_SerializedObject.ApplyModifiedProperties(); } else { EditorGUILayout.HelpBox(s_Styles.LightmapInfoBox.text, MessageType.Info); } }
public void RenderMeshSettings(bool showLightmapSettings) { if (LightingSettingsInspector.s_Styles == null) { LightingSettingsInspector.s_Styles = new LightingSettingsInspector.Styles(); } if (this.m_SerializedObject != null && this.m_GameObjectsSerializedObject != null && this.m_GameObjectsSerializedObject.targetObjects.Length != 0) { this.m_GameObjectsSerializedObject.Update(); this.m_LightmapSettings.Update(); EditorGUILayout.PropertyField(this.m_CastShadows, LightingSettingsInspector.s_Styles.CastShadows, true, new GUILayoutOption[0]); bool disabled = SceneView.IsUsingDeferredRenderingPath(); if (SupportedRenderingFeatures.active.rendererSupportsReceiveShadows) { using (new EditorGUI.DisabledScope(disabled)) { EditorGUILayout.PropertyField(this.m_ReceiveShadows, LightingSettingsInspector.s_Styles.ReceiveShadows, true, new GUILayoutOption[0]); } } if (SupportedRenderingFeatures.active.rendererSupportsMotionVectors) { EditorGUILayout.PropertyField(this.m_MotionVectors, LightingSettingsInspector.s_Styles.MotionVectors, true, new GUILayoutOption[0]); } if (showLightmapSettings) { this.LightmapStaticSettings(); if (!this.m_EnabledBakedGI.boolValue && !this.m_EnabledRealtimeGI.boolValue && !this.isPrefabAsset) { EditorGUILayout.HelpBox(LightingSettingsInspector.s_Styles.GINotEnabledInfo.text, MessageType.Info); } else { bool flag = (this.m_StaticEditorFlags.intValue & 1) != 0; if (flag) { bool flag2 = this.isPrefabAsset || this.m_EnabledRealtimeGI.boolValue || (this.m_EnabledBakedGI.boolValue && LightmapEditorSettings.lightmapper == LightmapEditorSettings.Lightmapper.Radiosity); bool flag3 = this.isPrefabAsset || (this.m_EnabledBakedGI.boolValue && LightmapEditorSettings.lightmapper != LightmapEditorSettings.Lightmapper.Radiosity); if (flag2) { this.m_ShowChartingSettings = EditorGUILayout.Foldout(this.m_ShowChartingSettings, LightingSettingsInspector.s_Styles.UVCharting); if (this.m_ShowChartingSettings) { this.RendererUVSettings(); } } this.m_ShowLightmapSettings = EditorGUILayout.Foldout(this.m_ShowLightmapSettings, LightingSettingsInspector.s_Styles.LightmapSettings); if (this.m_ShowLightmapSettings) { EditorGUI.indentLevel++; float num = LightmapVisualization.GetLightmapLODLevelScale(this.m_Renderers[0]); for (int i = 1; i < this.m_Renderers.Length; i++) { if (!Mathf.Approximately(num, LightmapVisualization.GetLightmapLODLevelScale(this.m_Renderers[i]))) { num = 1f; } } float lightmapScale = this.LightmapScaleGUI(num) * LightmapVisualization.GetLightmapLODLevelScale(this.m_Renderers[0]); float cachedMeshSurfaceArea = InternalMeshUtil.GetCachedMeshSurfaceArea((MeshRenderer)this.m_Renderers[0]); this.ShowClampedSizeInLightmapGUI(lightmapScale, cachedMeshSurfaceArea); if (flag2) { EditorGUILayout.PropertyField(this.m_ImportantGI, LightingSettingsInspector.s_Styles.ImportantGI, new GUILayoutOption[0]); } if (flag3) { EditorGUILayout.PropertyField(this.m_StitchLightmapSeams, LightingSettingsInspector.s_Styles.StitchLightmapSeams, new GUILayoutOption[0]); } LightingSettingsInspector.LightmapParametersGUI(this.m_LightmapParameters, LightingSettingsInspector.s_Styles.LightmapParameters); this.m_ShowBakedLM = EditorGUILayout.Foldout(this.m_ShowBakedLM, LightingSettingsInspector.s_Styles.Atlas); if (this.m_ShowBakedLM) { this.ShowAtlasGUI(this.m_Renderers[0].GetInstanceID()); } this.m_ShowRealtimeLM = EditorGUILayout.Foldout(this.m_ShowRealtimeLM, LightingSettingsInspector.s_Styles.RealtimeLM); if (this.m_ShowRealtimeLM) { this.ShowRealtimeLMGUI(this.m_Renderers[0]); } EditorGUI.indentLevel--; } if (LightmapEditorSettings.HasZeroAreaMesh(this.m_Renderers[0])) { EditorGUILayout.HelpBox(LightingSettingsInspector.s_Styles.ZeroAreaPackingMesh.text, MessageType.Warning); } if (LightmapEditorSettings.HasClampedResolution(this.m_Renderers[0])) { EditorGUILayout.HelpBox(LightingSettingsInspector.s_Styles.ClampedPackingResolution.text, MessageType.Warning); } if (!LightingSettingsInspector.HasNormals(this.m_Renderers[0])) { EditorGUILayout.HelpBox(LightingSettingsInspector.s_Styles.NoNormalsNoLightmapping.text, MessageType.Warning); } if (LightmapEditorSettings.HasUVOverlaps(this.m_Renderers[0])) { EditorGUILayout.HelpBox(LightingSettingsInspector.s_Styles.UVOverlap.text, MessageType.Warning); } this.m_SerializedObject.ApplyModifiedProperties(); } else { EditorGUILayout.HelpBox(LightingSettingsInspector.s_Styles.LightmapInfoBox.text, MessageType.Info); } } } } }