void ShowAtlasGUI(int instanceID) { EditorGUI.indentLevel += 1; Hash128 instanceHash; LightmapEditorSettings.GetPVRInstanceHash(instanceID, out instanceHash); EditorGUILayout.LabelField(s_Styles.PVRInstanceHash, GUIContent.Temp(instanceHash.ToString())); Hash128 atlasHash; LightmapEditorSettings.GetPVRAtlasHash(instanceID, out atlasHash); EditorGUILayout.LabelField(s_Styles.PVRAtlasHash, GUIContent.Temp(atlasHash.ToString())); int atlasInstanceOffset; LightmapEditorSettings.GetPVRAtlasInstanceOffset(instanceID, out atlasInstanceOffset); EditorGUILayout.LabelField(s_Styles.PVRAtlasInstanceOffset, GUIContent.Temp(atlasInstanceOffset.ToString())); EditorGUILayout.LabelField(s_Styles.AtlasIndex, GUIContent.Temp(m_LightmapIndex.intValue.ToString())); EditorGUILayout.LabelField(s_Styles.AtlasTilingX, GUIContent.Temp(m_LightmapTilingOffsetX.floatValue.ToString())); EditorGUILayout.LabelField(s_Styles.AtlasTilingY, GUIContent.Temp(m_LightmapTilingOffsetY.floatValue.ToString())); EditorGUILayout.LabelField(s_Styles.AtlasOffsetX, GUIContent.Temp(m_LightmapTilingOffsetZ.floatValue.ToString())); EditorGUILayout.LabelField(s_Styles.AtlasOffsetY, GUIContent.Temp(m_LightmapTilingOffsetW.floatValue.ToString())); EditorGUI.indentLevel -= 1; }
private void DisplayMeshWarning() { Mesh mesh = GetSharedMesh(m_Renderers[0]); bool showEnlightenSettings = isPrefabAsset || m_EnabledRealtimeGI.boolValue || (m_EnabledBakedGI.boolValue && LightmapEditorSettings.lightmapper == LightmapEditorSettings.Lightmapper.Enlighten); if (!HasSupportedTopologyForGI(mesh)) { EditorGUILayout.HelpBox(Styles.UnsupportedTopology.text, MessageType.Warning); return; } if (!HasVertices(mesh)) { EditorGUILayout.HelpBox(Styles.NoVerticesNoLightmapping.text, MessageType.Warning); return; } if (!HasNormals(mesh)) { EditorGUILayout.HelpBox(Styles.NoNormalsNoLightmapping.text, MessageType.Warning); return; } if (showEnlightenSettings) { if (LightmapEditorSettings.HasZeroAreaMesh(m_Renderers[0])) { EditorGUILayout.HelpBox(Styles.ZeroAreaPackingMesh.text, MessageType.Warning); return; } } }
public override void OnOpen() { SerializedObject serializedObject = new SerializedObject(LightmapEditorSettings.GetLightmapSettings()); this.m_EnableRealtimeGI = serializedObject.FindProperty("m_GISettings.m_EnableRealtimeLightmaps"); this.m_EnableBakedGI = serializedObject.FindProperty("m_GISettings.m_EnableBakedLightmaps"); }
public void UpdateActiveGameObjectSelection() { MeshRenderer renderer; Terrain terrain = null; // if the active object in the selection is a renderer or a terrain, we're interested in it's lightmapIndex if (Selection.activeGameObject == null || ((renderer = Selection.activeGameObject.GetComponent <MeshRenderer>()) == null && (terrain = Selection.activeGameObject.GetComponent <Terrain>()) == null)) { m_ActiveGameObjectLightmapIndex = -1; m_ActiveGameObjectTextureHash = new Hash128(); return; } if (isRealtimeLightmap) { Hash128 inputSystemHash; if ((renderer != null && LightmapEditorSettings.GetInputSystemHash(renderer.GetInstanceID(), out inputSystemHash)) || (terrain != null && LightmapEditorSettings.GetInputSystemHash(terrain.GetInstanceID(), out inputSystemHash))) { m_ActiveGameObjectTextureHash = inputSystemHash; } else { m_ActiveGameObjectTextureHash = new Hash128(); } } else { m_ActiveGameObjectLightmapIndex = renderer != null ? renderer.lightmapIndex : terrain.lightmapIndex; } m_ShouldScrollToLightmapIndex = true; }
private bool CheckCachedObject() { UnityEngine.Object lightmapSettings = LightmapEditorSettings.GetLightmapSettings(); bool result; if (lightmapSettings == null) { result = false; } else if (lightmapSettings == this.m_cachedObject) { this.m_so.UpdateIfRequiredOrScript(); result = true; } else { this.m_cachedObject = lightmapSettings; this.m_so = new SerializedObject(lightmapSettings); this.m_enableRealtimeGI = this.m_so.FindProperty("m_GISettings.m_EnableRealtimeLightmaps"); this.m_mixedBakeMode = this.m_so.FindProperty("m_LightmapEditorSettings.m_MixedBakeMode"); this.m_useShadowmask = this.m_so.FindProperty("m_UseShadowmask"); this.m_enabledBakedGI = this.m_so.FindProperty("m_GISettings.m_EnableBakedLightmaps"); this.m_workflowMode = this.m_so.FindProperty("m_GIWorkflowMode"); this.m_environmentMode = this.m_so.FindProperty("m_GISettings.m_EnvironmentLightingMode"); result = true; } return(result); }
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); LightmapData[] lightmaps = LightmapSettings.lightmaps; this.m_ScrollPositionMaps = GUILayout.BeginScrollView(this.m_ScrollPositionMaps, new GUILayoutOption[0]); using (new EditorGUI.DisabledScope(true)) { for (int i = 0; i < lightmaps.Length; i++) { GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.FlexibleSpace(); GUILayout.Label(i.ToString(), new GUILayoutOption[0]); GUILayout.Space(5f); lightmaps[i].lightmapLight = this.LightmapField(lightmaps[i].lightmapLight, i); GUILayout.Space(10f); lightmaps[i].lightmapDir = this.LightmapField(lightmaps[i].lightmapDir, i); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } } GUILayout.EndScrollView(); }
public void Maps() { if (s_Styles == null) { s_Styles = new Styles(); } GUI.changed = false; if (Lightmapping.giWorkflowMode == Lightmapping.GIWorkflowMode.OnDemand) { SerializedObject obj2 = new SerializedObject(LightmapEditorSettings.GetLightmapSettings()); EditorGUILayout.PropertyField(obj2.FindProperty("m_LightingDataAsset"), s_Styles.LightingDataAsset, new GUILayoutOption[0]); obj2.ApplyModifiedProperties(); } GUILayout.Space(10f); LightmapData[] lightmaps = LightmapSettings.lightmaps; this.m_ScrollPositionMaps = GUILayout.BeginScrollView(this.m_ScrollPositionMaps, new GUILayoutOption[0]); EditorGUI.BeginDisabledGroup(true); for (int i = 0; i < lightmaps.Length; i++) { GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.FlexibleSpace(); GUILayout.Label(i.ToString(), new GUILayoutOption[0]); GUILayout.Space(5f); lightmaps[i].lightmapFar = this.LightmapField(lightmaps[i].lightmapFar, i); GUILayout.Space(10f); lightmaps[i].lightmapNear = this.LightmapField(lightmaps[i].lightmapNear, i); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } EditorGUI.EndDisabledGroup(); GUILayout.EndScrollView(); }
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 ShowRealtimeLMGUI(SerializedObject so, Renderer renderer) { Hash128 hash; Hash128 hash2; int num; int num2; Hash128 hash3; int num3; int num4; EditorGUI.indentLevel++; if (LightmapEditorSettings.GetInstanceHash(renderer, out hash)) { EditorGUILayout.LabelField(s_Styles.RealtimeLMInstanceHash, new GUIContent(hash.ToString()), new GUILayoutOption[0]); } if (LightmapEditorSettings.GetGeometryHash(renderer, out hash2)) { EditorGUILayout.LabelField(s_Styles.RealtimeLMGeometryHash, new GUIContent(hash2.ToString()), new GUILayoutOption[0]); } if (LightmapEditorSettings.GetInstanceResolution(renderer, out num, out num2)) { EditorGUILayout.LabelField(s_Styles.RealtimeLMInstanceResolution, new GUIContent(num.ToString() + "x" + num2.ToString()), new GUILayoutOption[0]); } if (LightmapEditorSettings.GetInputSystemHash(renderer, out hash3)) { EditorGUILayout.LabelField(s_Styles.RealtimeLMInputSystemHash, new GUIContent(hash3.ToString()), new GUILayoutOption[0]); } if (LightmapEditorSettings.GetSystemResolution(renderer, out num3, out num4)) { EditorGUILayout.LabelField(s_Styles.RealtimeLMResolution, new GUIContent(num3.ToString() + "x" + num4.ToString()), new GUILayoutOption[0]); } EditorGUI.indentLevel--; }
public LightingSettingsInspector(SerializedObject serializedObject) { m_SerializedObject = serializedObject; m_GameObjectsSerializedObject = new SerializedObject(serializedObject.targetObjects.Select(t => ((Component)t).gameObject).ToArray()); m_ImportantGI = m_SerializedObject.FindProperty("m_ImportantGI"); m_StitchLightmapSeams = m_SerializedObject.FindProperty("m_StitchLightmapSeams"); m_LightmapParameters = m_SerializedObject.FindProperty("m_LightmapParameters"); m_LightmapIndex = m_SerializedObject.FindProperty("m_LightmapIndex"); m_LightmapTilingOffsetX = m_SerializedObject.FindProperty("m_LightmapTilingOffset.x"); m_LightmapTilingOffsetY = m_SerializedObject.FindProperty("m_LightmapTilingOffset.y"); m_LightmapTilingOffsetZ = m_SerializedObject.FindProperty("m_LightmapTilingOffset.z"); m_LightmapTilingOffsetW = m_SerializedObject.FindProperty("m_LightmapTilingOffset.w"); m_PreserveUVs = m_SerializedObject.FindProperty("m_PreserveUVs"); m_AutoUVMaxDistance = m_SerializedObject.FindProperty("m_AutoUVMaxDistance"); m_IgnoreNormalsForChartDetection = m_SerializedObject.FindProperty("m_IgnoreNormalsForChartDetection"); m_AutoUVMaxAngle = m_SerializedObject.FindProperty("m_AutoUVMaxAngle"); m_MinimumChartSize = m_SerializedObject.FindProperty("m_MinimumChartSize"); m_LightmapScale = m_SerializedObject.FindProperty("m_ScaleInLightmap"); m_CastShadows = m_SerializedObject.FindProperty("m_CastShadows"); m_ReceiveShadows = m_SerializedObject.FindProperty("m_ReceiveShadows"); m_ReceiveGI = m_SerializedObject.FindProperty("m_ReceiveGI"); m_Renderers = m_SerializedObject.targetObjects.OfType <Renderer>().ToArray(); m_Terrains = m_SerializedObject.targetObjects.OfType <Terrain>().ToArray(); m_StaticEditorFlags = m_GameObjectsSerializedObject.FindProperty("m_StaticEditorFlags"); m_LightmapSettings = new SerializedObject(LightmapEditorSettings.GetLightmapSettings()); m_EnabledBakedGI = m_LightmapSettings.FindProperty("m_GISettings.m_EnableBakedLightmaps"); m_EnabledRealtimeGI = m_LightmapSettings.FindProperty("m_GISettings.m_EnableRealtimeLightmaps"); }
public bool EditRenderers() { GameObject[] objArray; System.Type[] types = new System.Type[] { typeof(MeshRenderer), typeof(SkinnedMeshRenderer) }; Renderer[] selectedObjectsOfType = SceneModeUtility.GetSelectedObjectsOfType <Renderer>(out objArray, types); if (objArray.Length == 0) { return(false); } EditorGUILayout.InspectorTitlebar(selectedObjectsOfType); SerializedObject obj2 = new SerializedObject(objArray); using (new EditorGUI.DisabledScope(!SceneModeUtility.StaticFlagField("Lightmap Static", obj2.FindProperty("m_StaticEditorFlags"), 1))) { SerializedObject so = new SerializedObject(selectedObjectsOfType); float lightmapLODLevelScale = LightmapVisualization.GetLightmapLODLevelScale(selectedObjectsOfType[0]); for (int i = 1; i < selectedObjectsOfType.Length; i++) { if (!Mathf.Approximately(lightmapLODLevelScale, LightmapVisualization.GetLightmapLODLevelScale(selectedObjectsOfType[i]))) { lightmapLODLevelScale = 1f; } } float lightmapScale = this.LightmapScaleGUI(so, lightmapLODLevelScale) * 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); EditorGUILayout.PropertyField(so.FindProperty("m_ImportantGI"), s_Styles.ImportantGI, new GUILayoutOption[0]); LightmapParametersGUI(so.FindProperty("m_LightmapParameters"), s_Styles.LightmapParameters, true); GUILayout.Space(10f); this.RendererUVSettings(so); GUILayout.Space(10f); this.m_ShowBakedLM = EditorGUILayout.Foldout(this.m_ShowBakedLM, s_Styles.Atlas, true); if (this.m_ShowBakedLM) { this.ShowAtlasGUI(so); } this.m_ShowRealtimeLM = EditorGUILayout.Foldout(this.m_ShowRealtimeLM, s_Styles.RealtimeLM, true); if (this.m_ShowRealtimeLM) { this.ShowRealtimeLMGUI(so, selectedObjectsOfType[0]); } if (LightmapEditorSettings.HasZeroAreaMesh(selectedObjectsOfType[0])) { EditorGUILayout.HelpBox(s_Styles.ZeroAreaPackingMesh.text, MessageType.Warning); } if (LightmapEditorSettings.HasClampedResolution(selectedObjectsOfType[0])) { EditorGUILayout.HelpBox(s_Styles.ClampedPackingResolution.text, MessageType.Warning); } if (!HasNormals(selectedObjectsOfType[0])) { EditorGUILayout.HelpBox(s_Styles.NoNormalsNoLightmapping.text, MessageType.Warning); } obj2.ApplyModifiedProperties(); so.ApplyModifiedProperties(); } GUILayout.Space(10f); return(true); }
private void InitSettings() { if (m_LightmapSettings == null || m_LightmapSettings.targetObject == null || m_LightmapSettings.targetObject != LightmapEditorSettings.GetLightmapSettings()) { m_LightmapSettings = new SerializedObject(LightmapEditorSettings.GetLightmapSettings()); m_LightingDataAsset = m_LightmapSettings.FindProperty("m_LightingDataAsset"); } }
void InitLightmapSettings() { if (m_LightmapSettings == null || m_LightmapSettings.targetObject == null) { m_LightmapSettings = new SerializedObject(LightmapEditorSettings.GetLightmapSettings()); m_EnabledBakedGI = m_LightmapSettings.FindProperty("m_GISettings.m_EnableBakedLightmaps"); m_WorkflowMode = m_LightmapSettings.FindProperty("m_GIWorkflowMode"); } }
private void EnlightenBakeSettings() { SerializedObject serializedObject = new SerializedObject(LightmapEditorSettings.GetLightmapSettings()); SerializedProperty enableRealtimeGI = serializedObject.FindProperty("m_GISettings.m_EnableRealtimeLightmaps"); SerializedProperty enableBakedGI = serializedObject.FindProperty("m_GISettings.m_EnableBakedLightmaps"); this.RealtimeGUI(serializedObject, enableRealtimeGI, enableBakedGI); this.BakedGUI(serializedObject, enableRealtimeGI, enableBakedGI); this.GeneralSettingsGUI(serializedObject, enableRealtimeGI, enableBakedGI); serializedObject.ApplyModifiedProperties(); }
private void EnlightenBakeSettings() { SerializedObject so = new SerializedObject(LightmapEditorSettings.GetLightmapSettings()); SerializedProperty property1 = so.FindProperty("m_GISettings.m_EnableRealtimeLightmaps"); SerializedProperty property2 = so.FindProperty("m_GISettings.m_EnableBakedLightmaps"); this.RealtimeGUI(so, property1, property2); this.BakedGUI(so, property1, property2); this.GeneralSettingsGUI(so, property1, property2); so.ApplyModifiedProperties(); }
public void OnGUI() { if (this.m_LightmapSettings == null || this.m_LightmapSettings != LightmapEditorSettings.GetLightmapSettings()) { this.InitSettings(); } this.m_LightmapSettingsSO.UpdateIfRequiredOrScript(); this.RealtimeLightingGUI(); this.MixedLightingGUI(); this.GeneralLightmapSettingsGUI(); this.m_LightmapSettingsSO.ApplyModifiedProperties(); }
private void InitSettings() { Object renderSettings = RenderSettings.GetRenderSettings(); SerializedObject rso = m_RenderSettingsSO = new SerializedObject(renderSettings); m_SubtractiveShadowColor = rso.FindProperty("m_SubtractiveShadowColor"); m_LightmapSettings = LightmapEditorSettings.GetLightmapSettings(); SerializedObject so = m_LightmapSettingsSO = new SerializedObject(m_LightmapSettings); //realtime GI m_EnableRealtimeGI = so.FindProperty("m_GISettings.m_EnableRealtimeLightmaps"); m_Resolution = so.FindProperty("m_LightmapEditorSettings.m_Resolution"); //baked m_MixedBakeMode = so.FindProperty("m_LightmapEditorSettings.m_MixedBakeMode"); m_EnabledBakedGI = so.FindProperty("m_GISettings.m_EnableBakedLightmaps"); m_AlbedoBoost = so.FindProperty("m_GISettings.m_AlbedoBoost"); m_IndirectOutputScale = so.FindProperty("m_GISettings.m_IndirectOutputScale"); m_LightmapParameters = so.FindProperty("m_LightmapEditorSettings.m_LightmapParameters"); m_LightmapDirectionalMode = so.FindProperty("m_LightmapEditorSettings.m_LightmapsBakeMode"); m_BakeResolution = so.FindProperty("m_LightmapEditorSettings.m_BakeResolution"); m_Padding = so.FindProperty("m_LightmapEditorSettings.m_Padding"); m_AmbientOcclusion = so.FindProperty("m_LightmapEditorSettings.m_AO"); m_AOMaxDistance = so.FindProperty("m_LightmapEditorSettings.m_AOMaxDistance"); m_CompAOExponent = so.FindProperty("m_LightmapEditorSettings.m_CompAOExponent"); m_CompAOExponentDirect = so.FindProperty("m_LightmapEditorSettings.m_CompAOExponentDirect"); m_TextureCompression = so.FindProperty("m_LightmapEditorSettings.m_TextureCompression"); m_FinalGather = so.FindProperty("m_LightmapEditorSettings.m_FinalGather"); m_FinalGatherRayCount = so.FindProperty("m_LightmapEditorSettings.m_FinalGatherRayCount"); m_FinalGatherFiltering = so.FindProperty("m_LightmapEditorSettings.m_FinalGatherFiltering"); m_LightmapSize = so.FindProperty("m_LightmapEditorSettings.m_AtlasSize"); m_BakeBackend = so.FindProperty("m_LightmapEditorSettings.m_BakeBackend"); //m_PVRSampling = so.FindProperty("m_LightmapEditorSettings.m_PVRSampling"); // TODO(PVR): make non-fixed sampling modes work. m_PVRSampleCount = so.FindProperty("m_LightmapEditorSettings.m_PVRSampleCount"); m_PVRDirectSampleCount = so.FindProperty("m_LightmapEditorSettings.m_PVRDirectSampleCount"); m_PVRBounces = so.FindProperty("m_LightmapEditorSettings.m_PVRBounces"); m_PVRCulling = so.FindProperty("m_LightmapEditorSettings.m_PVRCulling"); m_PVRFilteringMode = so.FindProperty("m_LightmapEditorSettings.m_PVRFilteringMode"); m_PVRFilterTypeDirect = so.FindProperty("m_LightmapEditorSettings.m_PVRFilterTypeDirect"); m_PVRFilterTypeIndirect = so.FindProperty("m_LightmapEditorSettings.m_PVRFilterTypeIndirect"); m_PVRFilterTypeAO = so.FindProperty("m_LightmapEditorSettings.m_PVRFilterTypeAO"); m_PVRFilteringGaussRadiusDirect = so.FindProperty("m_LightmapEditorSettings.m_PVRFilteringGaussRadiusDirect"); m_PVRFilteringGaussRadiusIndirect = so.FindProperty("m_LightmapEditorSettings.m_PVRFilteringGaussRadiusIndirect"); m_PVRFilteringGaussRadiusAO = so.FindProperty("m_LightmapEditorSettings.m_PVRFilteringGaussRadiusAO"); m_PVRFilteringAtrousPositionSigmaDirect = so.FindProperty("m_LightmapEditorSettings.m_PVRFilteringAtrousPositionSigmaDirect"); m_PVRFilteringAtrousPositionSigmaIndirect = so.FindProperty("m_LightmapEditorSettings.m_PVRFilteringAtrousPositionSigmaIndirect"); m_PVRFilteringAtrousPositionSigmaAO = so.FindProperty("m_LightmapEditorSettings.m_PVRFilteringAtrousPositionSigmaAO"); //dev debug properties m_BounceScale = so.FindProperty("m_GISettings.m_BounceScale"); m_UpdateThreshold = so.FindProperty("m_GISettings.m_TemporalCoherenceThreshold"); }
static public bool LightmapParametersGUI(SerializedProperty prop, GUIContent content) { EditorGUILayout.BeginHorizontal(); EditorGUIInternal.AssetPopup <LightmapParameters>(prop, content, "giparams", "Scene Default Parameters"); string label = "Edit..."; if (isBuiltIn(prop)) { label = "View"; } bool editClicked = false; // If object is null, then get the scene parameter setting and view this instead. if (prop.objectReferenceValue == null) { SerializedObject so = new SerializedObject(LightmapEditorSettings.GetLightmapSettings()); SerializedProperty lightmapParameters = so.FindProperty("m_LightmapEditorSettings.m_LightmapParameters"); using (new EditorGUI.DisabledScope(lightmapParameters == null)) { if (isBuiltIn(lightmapParameters)) { label = "View"; } else { label = "Edit..."; } if (GUILayout.Button(label, EditorStyles.miniButton, GUILayout.ExpandWidth(false))) { Selection.activeObject = lightmapParameters.objectReferenceValue; editClicked = true; } } } else { if (GUILayout.Button(label, EditorStyles.miniButton, GUILayout.ExpandWidth(false))) { Selection.activeObject = prop.objectReferenceValue; editClicked = true; } } EditorGUILayout.EndHorizontal(); return(editClicked); }
internal void OnGUI(Renderer renderer, bool useMiniStyle) { if (this.m_UseLightProbes != null) { EditorGUI.BeginDisabledGroup(LightmapEditorSettings.IsLightmappedOrDynamicLightmappedForRendering(renderer)); if (!useMiniStyle) { EditorGUILayout.PropertyField(this.m_UseLightProbes, this.m_UseLightProbesStyle, new GUILayoutOption[0]); } else { ModuleUI.GUIToggle(this.m_UseLightProbesStyle, this.m_UseLightProbes); } EditorGUI.EndDisabledGroup(); } if (!useMiniStyle) { this.m_ReflectionProbeUsage.intValue = (int)((ReflectionProbeUsage)EditorGUILayout.EnumPopup(this.m_ReflectionProbeUsageStyle, (ReflectionProbeUsage)this.m_ReflectionProbeUsage.intValue, new GUILayoutOption[0])); } else { ModuleUI.GUIPopup(this.m_ReflectionProbeUsageStyle, this.m_ReflectionProbeUsage, Enum.GetNames(typeof(ReflectionProbeUsage))); } bool flag = this.m_ReflectionProbeUsage.intValue != 0; if (((this.m_UseLightProbes != null) && this.m_UseLightProbes.boolValue) || flag) { EditorGUI.indentLevel++; if (!useMiniStyle) { EditorGUILayout.PropertyField(this.m_ProbeAnchor, this.m_ProbeAnchorStyle, new GUILayoutOption[0]); } else { ModuleUI.GUIObject(this.m_ProbeAnchorStyle, this.m_ProbeAnchor); } if (flag) { if (SceneView.GetSceneViewRenderingPath() == RenderingPath.DeferredShading) { EditorGUILayout.HelpBox(this.m_DeferredNote.text, MessageType.Info); } else { renderer.GetClosestReflectionProbes(this.m_BlendInfo); ShowClosestReflectionProbes(this.m_BlendInfo); } } EditorGUI.indentLevel--; } }
void ShowRealtimeLMGUI(Terrain terrain) { Hash128 inputSystemHash; if (terrain == null || !LightmapEditorSettings.GetInputSystemHash(terrain.GetInstanceID(), out inputSystemHash) || inputSystemHash == new Hash128()) { return; // early return since we don't have any lightmaps for it } if (!UpdateRealtimeTexture(inputSystemHash, terrain.GetInstanceID())) { return; } m_ShowRealtimeLM.value = EditorGUILayout.Foldout(m_ShowRealtimeLM.value, Styles.RealtimeLM, true); if (!m_ShowRealtimeLM.value) { return; } EditorGUI.indentLevel += 1; GUILayout.BeginHorizontal(); DrawLightmapPreview(m_CachedRealtimeTexture.texture, true, terrain.GetInstanceID()); GUILayout.BeginVertical(); // Resolution of the system. int width, height; int numChunksInX, numChunksInY; if (LightmapEditorSettings.GetTerrainSystemResolution(terrain, out width, out height, out numChunksInX, out numChunksInY)) { var str = width.ToString() + "x" + height.ToString(); if (numChunksInX > 1 || numChunksInY > 1) { str += string.Format(" ({0}x{1} chunks)", numChunksInX, numChunksInY); } GUILayout.Label(Styles.RealtimeLMResolution.text + ": " + str); } GUILayout.EndVertical(); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); EditorGUI.indentLevel -= 1; GUILayout.Space(5); }
private void EnlightenBakeSettings() { SerializedObject serializedObject = new SerializedObject(LightmapEditorSettings.GetLightmapSettings()); SerializedProperty serializedProperty = serializedObject.FindProperty("m_GISettings.m_EnableRealtimeLightmaps"); SerializedProperty serializedProperty2 = serializedObject.FindProperty("m_GISettings.m_EnableBakedLightmaps"); bool boolValue = serializedProperty.boolValue; this.RealtimeGUI(serializedObject, serializedProperty); this.BakedGUI(serializedObject, serializedProperty.boolValue, serializedProperty2); this.GeneralSettingsGUI(serializedObject, serializedProperty.boolValue, serializedProperty2.boolValue); if (serializedProperty2.boolValue && serializedProperty.boolValue && !boolValue) { Lightmapping.ClearPrecompSetIsDone(); } serializedObject.ApplyModifiedProperties(); }
private void EnlightenBakeSettings() { SerializedObject so = new SerializedObject(LightmapEditorSettings.GetLightmapSettings()); SerializedProperty enableRealtimeGI = so.FindProperty("m_GISettings.m_EnableRealtimeLightmaps"); SerializedProperty enableBakedGI = so.FindProperty("m_GISettings.m_EnableBakedLightmaps"); bool boolValue = enableRealtimeGI.boolValue; this.RealtimeGUI(so, enableRealtimeGI); this.BakedGUI(so, enableRealtimeGI.boolValue, enableBakedGI); this.GeneralSettingsGUI(so, enableRealtimeGI.boolValue, enableBakedGI.boolValue); if ((enableBakedGI.boolValue && enableRealtimeGI.boolValue) && !boolValue) { Lightmapping.ClearPrecompSetIsDone(); } so.ApplyModifiedProperties(); }
public static bool LightmapParametersGUI(SerializedProperty prop, GUIContent content) { EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]); EditorGUIInternal.AssetPopup <LightmapParameters>(prop, content, "giparams", "Scene Default Parameters"); string text = "Edit..."; if (LightingSettingsInspector.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 (LightingSettingsInspector.isBuiltIn(serializedProperty)) { text = "View"; } else { text = "Edit..."; } 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 ShowRealtimeLMGUI(Renderer renderer) { EditorGUI.indentLevel += 1; // The hash of the instance. Hash128 instanceHash; if (LightmapEditorSettings.GetInstanceHash(renderer, out instanceHash)) { EditorGUILayout.LabelField(s_Styles.RealtimeLMInstanceHash, GUIContent.Temp(instanceHash.ToString())); } // The hash of the geometry. Hash128 geometryHash; if (LightmapEditorSettings.GetGeometryHash(renderer, out geometryHash)) { EditorGUILayout.LabelField(s_Styles.RealtimeLMGeometryHash, GUIContent.Temp(geometryHash.ToString())); } // Resolution of the packed instance. int instWidth, instHeight; if (LightmapEditorSettings.GetInstanceResolution(renderer, out instWidth, out instHeight)) { EditorGUILayout.LabelField(s_Styles.RealtimeLMInstanceResolution, GUIContent.Temp(instWidth.ToString() + "x" + instHeight.ToString())); } // The hash of the system. Hash128 inputSystemHash; if (LightmapEditorSettings.GetInputSystemHash(renderer, out inputSystemHash)) { EditorGUILayout.LabelField(s_Styles.RealtimeLMInputSystemHash, GUIContent.Temp(inputSystemHash.ToString())); } // Resolution of the system. int width, height; if (LightmapEditorSettings.GetSystemResolution(renderer, out width, out height)) { EditorGUILayout.LabelField(s_Styles.RealtimeLMResolution, GUIContent.Temp(width.ToString() + "x" + height.ToString())); } EditorGUI.indentLevel -= 1; }
void InitLightmapSettings() { // the target gets destroyed and recreated when we setup a new scene, or when hitting play if (m_LightmapSettings == null || m_LightmapSettings.targetObject == null) { if (m_LightmapSettings != null) { m_LightmapSettings.Dispose(); m_EnabledBakedGI.Dispose(); m_WorkflowMode.Dispose(); } m_LightmapSettings = new SerializedObject(LightmapEditorSettings.GetLightmapSettings()); m_EnabledBakedGI = m_LightmapSettings.FindProperty("m_GISettings.m_EnableBakedLightmaps"); m_WorkflowMode = m_LightmapSettings.FindProperty("m_GIWorkflowMode"); } }
public virtual void OnEnable() { this.m_Sun = base.serializedObject.FindProperty("m_Sun"); this.m_AmbientMode = base.serializedObject.FindProperty("m_AmbientMode"); this.m_AmbientSkyColor = base.serializedObject.FindProperty("m_AmbientSkyColor"); this.m_AmbientEquatorColor = base.serializedObject.FindProperty("m_AmbientEquatorColor"); this.m_AmbientGroundColor = base.serializedObject.FindProperty("m_AmbientGroundColor"); this.m_AmbientIntensity = base.serializedObject.FindProperty("m_AmbientIntensity"); this.m_ReflectionIntensity = base.serializedObject.FindProperty("m_ReflectionIntensity"); this.m_ReflectionBounces = base.serializedObject.FindProperty("m_ReflectionBounces"); this.m_SkyboxMaterial = base.serializedObject.FindProperty("m_SkyboxMaterial"); this.m_DefaultReflectionMode = base.serializedObject.FindProperty("m_DefaultReflectionMode"); this.m_DefaultReflectionResolution = base.serializedObject.FindProperty("m_DefaultReflectionResolution"); this.m_CustomReflection = base.serializedObject.FindProperty("m_CustomReflection"); this.m_lightmapSettings = new SerializedObject(LightmapEditorSettings.GetLightmapSettings()); this.m_EnvironmentLightingMode = this.m_lightmapSettings.FindProperty("m_GISettings.m_EnvironmentLightingMode"); this.m_ShowEditor = InspectorState.GetBool("ShowLightingEditor", true); }
private void InitLightmapSettings() { Scene activeScene = SceneManager.GetActiveScene(); if (this.m_LastActiveScene != activeScene) { if (this.m_LightmapSettings != null) { this.m_LightmapSettings.Dispose(); this.m_EnabledBakedGI.Dispose(); this.m_WorkflowMode.Dispose(); } this.m_LastActiveScene = activeScene; this.m_LightmapSettings = new SerializedObject(LightmapEditorSettings.GetLightmapSettings()); this.m_EnabledBakedGI = this.m_LightmapSettings.FindProperty("m_GISettings.m_EnableBakedLightmaps"); this.m_WorkflowMode = this.m_LightmapSettings.FindProperty("m_GIWorkflowMode"); } }
void ShowRealtimeLMGUI(Renderer renderer) { EditorGUI.indentLevel += 1; Hash128 inputSystemHash = new Hash128(); if (renderer != null && LightmapEditorSettings.GetInputSystemHash(renderer.GetInstanceID(), out inputSystemHash)) { ShowRealtimeLightmapPreview(inputSystemHash); } int instWidth, instHeight; if (LightmapEditorSettings.GetInstanceResolution(renderer, out instWidth, out instHeight)) { EditorGUILayout.LabelField(Styles.RealtimeLMInstanceResolution, GUIContent.Temp(instWidth.ToString() + "x" + instHeight.ToString())); } int width, height; if (LightmapEditorSettings.GetSystemResolution(renderer, out width, out height)) { EditorGUILayout.LabelField(Styles.RealtimeLMResolution, GUIContent.Temp(width.ToString() + "x" + height.ToString())); } if (Unsupported.IsDeveloperMode()) { Hash128 instanceHash; if (LightmapEditorSettings.GetInstanceHash(renderer, out instanceHash)) { EditorGUILayout.LabelField(Styles.RealtimeLMInstanceHash, GUIContent.Temp(instanceHash.ToString())); } Hash128 geometryHash; if (LightmapEditorSettings.GetGeometryHash(renderer, out geometryHash)) { EditorGUILayout.LabelField(Styles.RealtimeLMGeometryHash, GUIContent.Temp(geometryHash.ToString())); } EditorGUILayout.LabelField(Styles.RealtimeLMInputSystemHash, GUIContent.Temp(inputSystemHash.ToString())); } EditorGUI.indentLevel -= 1; }
internal void OnGUI(UnityEngine.Object[] selection, Renderer renderer, bool useMiniStyle) { int selectionCount = 1; bool flag = SceneView.IsUsingDeferredRenderingPath(); bool flag2 = flag && UnityEngine.Rendering.GraphicsSettings.GetShaderMode(BuiltinShaderType.DeferredReflections) != BuiltinShaderMode.Disabled; bool usesLightMaps = false; if (selection != null) { for (int i = 0; i < selection.Length; i++) { UnityEngine.Object @object = selection[i]; if (LightmapEditorSettings.IsLightmappedOrDynamicLightmappedForRendering((Renderer)@object)) { usesLightMaps = true; break; } } selectionCount = selection.Length; } this.RenderLightProbeUsage(selectionCount, renderer, useMiniStyle, usesLightMaps); this.RenderReflectionProbeUsage(useMiniStyle, flag, flag2); bool flag3 = this.RenderProbeAnchor(useMiniStyle); if (flag3) { bool flag4 = !this.m_ReflectionProbeUsage.hasMultipleDifferentValues && this.m_ReflectionProbeUsage.intValue != 0; if (flag4) { if (!flag2) { renderer.GetClosestReflectionProbes(this.m_BlendInfo); RendererEditorBase.Probes.ShowClosestReflectionProbes(this.m_BlendInfo); } } } bool flag5 = !this.m_ReceiveShadows.hasMultipleDifferentValues && this.m_ReceiveShadows.boolValue; if ((flag && flag5) || (flag2 && flag3)) { EditorGUILayout.HelpBox(this.m_DeferredNote.text, MessageType.Info); } this.RenderLightProbeProxyVolumeWarningNote(renderer, selectionCount); }
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 (isBuiltIn(prop)) { text = "View"; } bool flag = false; if (prop.objectReferenceValue == null) { SerializedProperty property = new SerializedObject(LightmapEditorSettings.GetLightmapSettings()).FindProperty("m_LightmapEditorSettings.m_LightmapParameters"); using (new EditorGUI.DisabledScope(property == null)) { GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.ExpandWidth(false) }; if (GUILayout.Button(text, EditorStyles.miniButton, options)) { Selection.activeObject = property.objectReferenceValue; flag = true; } } } else { GUILayoutOption[] optionArray2 = new GUILayoutOption[] { GUILayout.ExpandWidth(false) }; if (GUILayout.Button(text, EditorStyles.miniButton, optionArray2)) { Selection.activeObject = prop.objectReferenceValue; flag = true; } } EditorGUILayout.EndHorizontal(); return(flag); }