You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
LODGeneratorHelper has two new properties,
A LODGeneratorPreset obj ref and a "customization" toggle.
If customization is enabled (default), the helper drives all properties itself.
If customization is disabled, properties are driven by a specified preset.
If no preset is specified, defaults matching previous behavior are used.
Copy file name to clipboardExpand all lines: Runtime/Components/LODGeneratorHelper.cs
+114-7Lines changed: 114 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -35,6 +35,12 @@ namespace UnityMeshSimplifier
35
35
publicsealedclassLODGeneratorHelper:MonoBehaviour
36
36
{
37
37
#region Fields
38
+
[SerializeField,Tooltip("The LOD Generator preset to use.")]
39
+
privateLODGeneratorPresetlodGeneratorPreset=null;
40
+
41
+
[SerializeField,Tooltip("Whether to enable customization of preset-derived generation settings.")]
42
+
privateboolcustomizeSettings=true;
43
+
38
44
[SerializeField,Tooltip("The fade mode used by the created LOD group.")]
39
45
privateLODFadeModefadeMode=LODFadeMode.None;
40
46
[SerializeField,Tooltip("If the cross-fading should be animated by time.")]
@@ -57,13 +63,41 @@ public sealed class LODGeneratorHelper : MonoBehaviour
57
63
#endregion
58
64
59
65
#region Properties
66
+
/// <summary>
67
+
/// Gets or sets a LOD generator preset. Presets can be used to drive simplification options and levels in a sharable way.
68
+
/// </summary>
69
+
publicLODGeneratorPresetLodGeneratorPreset
70
+
{
71
+
get{returnlodGeneratorPreset;}
72
+
set{lodGeneratorPreset=value;}
73
+
}
74
+
75
+
/// <summary>
76
+
/// Gets or sets if the simplification options and levels should be customizable, versus driven by the specified preset.
77
+
/// </summary>
78
+
publicboolCustomizeSettings
79
+
{
80
+
get{returncustomizeSettings;}
81
+
set{customizeSettings=value;}
82
+
}
83
+
60
84
/// <summary>
61
85
/// Gets or sets the fade mode used by the created LOD group.
62
86
/// </summary>
63
87
publicLODFadeModeFadeMode
64
88
{
65
89
get{returnfadeMode;}
66
-
set{fadeMode=value;}
90
+
set
91
+
{
92
+
if(!customizeSettings)
93
+
{
94
+
fadeMode=value;
95
+
}
96
+
else
97
+
{
98
+
WarnDisabledCustomization();
99
+
}
100
+
}
67
101
}
68
102
69
103
/// <summary>
@@ -73,7 +107,17 @@ public LODFadeMode FadeMode
73
107
publicboolAnimateCrossFading
74
108
{
75
109
get{returnanimateCrossFading;}
76
-
set{animateCrossFading=value;}
110
+
set
111
+
{
112
+
if(!customizeSettings)
113
+
{
114
+
animateCrossFading=value;
115
+
}
116
+
else
117
+
{
118
+
WarnDisabledCustomization();
119
+
}
120
+
}
77
121
}
78
122
79
123
/// <summary>
@@ -91,7 +135,17 @@ public bool AutoCollectRenderers
91
135
publicSimplificationOptionsSimplificationOptions
92
136
{
93
137
get{returnsimplificationOptions;}
94
-
set{simplificationOptions=value;}
138
+
set
139
+
{
140
+
if(!customizeSettings)
141
+
{
142
+
simplificationOptions=value;
143
+
}
144
+
else
145
+
{
146
+
WarnDisabledCustomization();
147
+
}
148
+
}
95
149
}
96
150
97
151
/// <summary>
@@ -110,7 +164,17 @@ public string SaveAssetsPath
110
164
publicLODLevel[]Levels
111
165
{
112
166
get{returnlevels;}
113
-
set{levels=value;}
167
+
set
168
+
{
169
+
if(!customizeSettings)
170
+
{
171
+
levels=value;
172
+
}
173
+
else
174
+
{
175
+
WarnDisabledCustomization();
176
+
}
177
+
}
114
178
}
115
179
116
180
/// <summary>
@@ -124,14 +188,57 @@ public bool IsGenerated
124
188
125
189
#region Unity Events
126
190
privatevoidReset()
191
+
{
192
+
autoCollectRenderers=true;
193
+
ResetPresetDerivedSettings();
194
+
}
195
+
196
+
privatevoidOnValidate()
197
+
{
198
+
if(!customizeSettings)
199
+
{
200
+
UpdateSettingsFromPreset();
201
+
}
202
+
}
203
+
#endregion
204
+
205
+
privatevoidWarnDisabledCustomization()
206
+
{
207
+
Debug.LogWarning($"Attempted to set a preset-driven property on a {typeof(LODGeneratorHelper)} while customization is disabled. Enable customization first.");
0 commit comments