@@ -57,6 +57,14 @@ public enum ColliderModification
57
57
public bool overrideAnchor ;
58
58
public Transform anchor ;
59
59
60
+ [ Header ( "Terrain Grouping ID" ) ]
61
+ public bool overrideTerrainGroupingId ;
62
+ public int terrainGroupingId ;
63
+
64
+ [ Header ( "Terrain Material" ) ]
65
+ public bool overrideTerrainMaterialTemplate ;
66
+ public Material terrainMaterialTemplate ;
67
+
60
68
private void Reset ( )
61
69
{
62
70
gameObject . tag = "EditorOnly" ;
@@ -151,6 +159,30 @@ public void Apply()
151
159
}
152
160
}
153
161
}
162
+
163
+ var terrains = transform . parent . GetComponentsInChildren < Terrain > ( true ) . ToArray ( ) ;
164
+ if ( overrideLightmapSettings )
165
+ {
166
+ var serializedObject = new SerializedObject ( terrains ) ;
167
+ serializedObject . FindProperty ( "m_ScaleInLightmap" ) . floatValue = lightmapScaleOffset ;
168
+ if ( lightmapParameters ) serializedObject . FindProperty ( "m_LightmapParameters" ) . objectReferenceValue = lightmapParameters ;
169
+ serializedObject . ApplyModifiedProperties ( ) ;
170
+ }
171
+
172
+ foreach ( var terrain in terrains )
173
+ {
174
+ if ( overrideTerrainGroupingId )
175
+ {
176
+ Undo . RecordObject ( terrain , "Override Terrain" ) ;
177
+ terrain . groupingID = terrainGroupingId ;
178
+ }
179
+
180
+ if ( overrideTerrainMaterialTemplate )
181
+ {
182
+ Undo . RecordObject ( terrain , "Override Terrain" ) ;
183
+ terrain . materialTemplate = terrainMaterialTemplate ;
184
+ }
185
+ }
154
186
}
155
187
#endif
156
188
}
0 commit comments