@@ -16,7 +16,6 @@ internal enum DefaultReflectionMode
16
16
Custom
17
17
}
18
18
19
- [ CustomEditor ( typeof ( RenderSettings ) ) ]
20
19
internal class LightingEditor : Editor
21
20
{
22
21
internal static class Styles
@@ -77,31 +76,38 @@ static Styles() {}
77
76
protected SerializedProperty m_CustomReflection ;
78
77
protected SerializedProperty m_ReflectionCompression ;
79
78
79
+ protected SerializedObject m_RenderSettings ;
80
80
protected SerializedObject m_LightmapSettings ;
81
81
82
82
private bool m_bShowEnvironment ;
83
83
private const string kShowEnvironment = "ShowEnvironment" ;
84
84
85
- public virtual void OnEnable ( )
85
+ private void InitSettings ( )
86
86
{
87
- m_Sun = serializedObject . FindProperty ( "m_Sun" ) ;
88
- m_AmbientSource = serializedObject . FindProperty ( "m_AmbientMode" ) ;
89
- m_AmbientSkyColor = serializedObject . FindProperty ( "m_AmbientSkyColor" ) ;
90
- m_AmbientEquatorColor = serializedObject . FindProperty ( "m_AmbientEquatorColor" ) ;
91
- m_AmbientGroundColor = serializedObject . FindProperty ( "m_AmbientGroundColor" ) ;
92
- m_AmbientIntensity = serializedObject . FindProperty ( "m_AmbientIntensity" ) ;
93
- m_ReflectionIntensity = serializedObject . FindProperty ( "m_ReflectionIntensity" ) ;
94
- m_ReflectionBounces = serializedObject . FindProperty ( "m_ReflectionBounces" ) ;
95
- m_SkyboxMaterial = serializedObject . FindProperty ( "m_SkyboxMaterial" ) ;
96
- m_DefaultReflectionMode = serializedObject . FindProperty ( "m_DefaultReflectionMode" ) ;
97
- m_DefaultReflectionResolution = serializedObject . FindProperty ( "m_DefaultReflectionResolution" ) ;
98
- m_CustomReflection = serializedObject . FindProperty ( "m_CustomReflection" ) ;
87
+ m_RenderSettings = new SerializedObject ( RenderSettings . GetRenderSettings ( ) ) ;
88
+ m_Sun = m_RenderSettings . FindProperty ( "m_Sun" ) ;
89
+ m_AmbientSource = m_RenderSettings . FindProperty ( "m_AmbientMode" ) ;
90
+ m_AmbientSkyColor = m_RenderSettings . FindProperty ( "m_AmbientSkyColor" ) ;
91
+ m_AmbientEquatorColor = m_RenderSettings . FindProperty ( "m_AmbientEquatorColor" ) ;
92
+ m_AmbientGroundColor = m_RenderSettings . FindProperty ( "m_AmbientGroundColor" ) ;
93
+ m_AmbientIntensity = m_RenderSettings . FindProperty ( "m_AmbientIntensity" ) ;
94
+ m_ReflectionIntensity = m_RenderSettings . FindProperty ( "m_ReflectionIntensity" ) ;
95
+ m_ReflectionBounces = m_RenderSettings . FindProperty ( "m_ReflectionBounces" ) ;
96
+ m_SkyboxMaterial = m_RenderSettings . FindProperty ( "m_SkyboxMaterial" ) ;
97
+ m_DefaultReflectionMode = m_RenderSettings . FindProperty ( "m_DefaultReflectionMode" ) ;
98
+ m_DefaultReflectionResolution = m_RenderSettings . FindProperty ( "m_DefaultReflectionResolution" ) ;
99
+ m_CustomReflection = m_RenderSettings . FindProperty ( "m_CustomReflection" ) ;
99
100
100
101
m_LightmapSettings = new SerializedObject ( LightmapEditorSettings . GetLightmapSettings ( ) ) ;
101
102
m_ReflectionCompression = m_LightmapSettings . FindProperty ( "m_LightmapEditorSettings.m_ReflectionCompression" ) ;
102
103
m_AmbientLightingMode = m_LightmapSettings . FindProperty ( "m_GISettings.m_EnvironmentLightingMode" ) ;
103
104
104
- m_bShowEnvironment = SessionState . GetBool ( kShowEnvironment , true ) ;
105
+ m_bShowEnvironment = SessionState . GetBool ( kShowEnvironment , true ) ;
106
+ }
107
+
108
+ public virtual void OnEnable ( )
109
+ {
110
+ InitSettings ( ) ;
105
111
}
106
112
107
113
public virtual void OnDisable ( )
@@ -111,6 +117,11 @@ public virtual void OnDisable()
111
117
112
118
private void DrawGUI ( )
113
119
{
120
+ if ( m_RenderSettings == null || m_RenderSettings . targetObject != RenderSettings . GetRenderSettings ( ) )
121
+ {
122
+ InitSettings ( ) ;
123
+ }
124
+
114
125
Material skyboxMaterial = m_SkyboxMaterial . objectReferenceValue as Material ;
115
126
116
127
m_bShowEnvironment = EditorGUILayout . FoldoutTitlebar ( m_bShowEnvironment , Styles . env_top , true ) ;
0 commit comments