Skip to content

Commit 75c70d7

Browse files
committed
Merge branch 'main' into localization-support
2 parents aec4149 + 67eced6 commit 75c70d7

File tree

3 files changed

+26
-22
lines changed

3 files changed

+26
-22
lines changed

Editor/MeshSimplifierOptionsDrawer.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,23 @@ public override VisualElement CreatePropertyGUI(SerializedProperty property)
2828
});
2929
var resetOptionsButton = root.Q<Button>("ResetOptionsButton");
3030
LocalizationProvider.LocalizeProperties<MeshSimplifierOptions>(root);
31+
32+
var enableSmartLinkToggle = root.Q<Toggle>("EnableSmartLinkToggle");
33+
var smartLinkOptionsGroup = root.Q<GroupBox>("SmartLinkOptionsGroup");
34+
3135
resetOptionsButton.clicked += () =>
3236
{
3337
property.boxedValue = MeshSimplifierOptions.Default;
3438
property.serializedObject.ApplyModifiedProperties();
3539
};
40+
41+
enableSmartLinkToggle.RegisterValueChangedCallback(changeEvent =>
42+
{
43+
smartLinkOptionsGroup.style.display = changeEvent.newValue ? DisplayStyle.Flex : DisplayStyle.None;
44+
45+
});
46+
47+
3648
return root;
3749
}
3850
}

Editor/MeshSimplifierOptionsDrawer.uxml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
<ui:Toggle label="Preserve Border Edges" binding-path="PreserveBorderEdges" />
44
<ui:Toggle label="Preserve Surface Curvature" binding-path="PreserveSurfaceCurvature" />
55
<ui:Toggle label="Use Barycentric Coordinate Interpolation" binding-path="UseBarycentricCoordinateInterpolation" />
6-
<ui:Toggle label="Enable Smart Link" binding-path="EnableSmartLink" value="true" />
76
<ui:Slider label="Min Normal Dot" high-value="1" binding-path="MinNormalDot" low-value="-1" />
8-
<ui:FloatField label="Vertex Link Distance" value="0.001" binding-path="VertexLinkDistance" />
9-
<ui:Slider label="Vertex Link Min Normal Dot" high-value="1" binding-path="VertexLinkMinNormalDot" low-value="-1" />
10-
<ui:FloatField label="Vertex Link Color Distance" value="0.01" binding-path="VertexLinkColorDistance" />
11-
<ui:Slider label="Vertex Link UV Distance" high-value="1.414214" binding-path="VertexLinkUvDistance" low-value="0" />
7+
<ui:Toggle label="Enable Smart Link" binding-path="EnableSmartLink" value="true" name="EnableSmartLinkToggle" />
8+
<ui:GroupBox text="Smart Link Options" name="SmartLinkOptionsGroup">
9+
<ui:FloatField label="Vertex Link Distance" value="0.001" binding-path="VertexLinkDistance" name="FloatField" />
10+
<ui:Slider label="Vertex Link Min Normal Dot" high-value="1" binding-path="VertexLinkMinNormalDot" low-value="-1" />
11+
<ui:FloatField label="Vertex Link Color Distance" value="0.01" binding-path="VertexLinkColorDistance" />
12+
<ui:Slider label="Vertex Link UV Distance" high-value="1.414214" binding-path="VertexLinkUvDistance" low-value="0" />
13+
</ui:GroupBox>
1214
<ui:Button text="Reset Options" parse-escape-sequences="true" display-tooltip-when-elided="true" name="ResetOptionsButton" enable-rich-text="false" />
1315
</ui:UXML>

Ndmf/Editor/MeshiaCascadingAvatarMeshSimplifierEditor.cs

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ internal class MeshiaCascadingAvatarMeshSimplifierEditor : UnityEditor.Editor
2323
private SerializedProperty TargetTriangleCountProperty => serializedObject.FindProperty(nameof(MeshiaCascadingAvatarMeshSimplifier.TargetTriangleCount));
2424
private SerializedProperty EntriesProperty => serializedObject.FindProperty(nameof(MeshiaCascadingAvatarMeshSimplifier.Entries));
2525

26-
Action<bool>? onNdmfPreviewEnabledChanged;
27-
2826

2927
[MenuItem("GameObject/Meshia Mesh Simplification/Meshia Cascading Avatar Mesh Simplifier", false, 0)]
3028
static void AddCascadingAvatarMeshSimplifier()
@@ -39,15 +37,6 @@ private void OnEnable()
3937
RefreshEntries();
4038
}
4139

42-
private void OnDisable()
43-
{
44-
if(onNdmfPreviewEnabledChanged != null)
45-
{
46-
MeshiaCascadingAvatarMeshSimplifierPreview.PreviewControlNode.IsEnabled.OnChange -= onNdmfPreviewEnabledChanged;
47-
onNdmfPreviewEnabledChanged = null;
48-
}
49-
}
50-
5140
private void RefreshEntries()
5241
{
5342
if(Target.transform.parent == null)
@@ -84,8 +73,6 @@ public override VisualElement CreateInspectorGUI()
8473
var targetTriangleCountPresetDropdownField = root.Q<DropdownField>("TargetTriangleCountPresetDropdownField");
8574
var adjustButton = root.Q<Button>("AdjustButton");
8675
var autoAdjustEnabledToggle = root.Q<Toggle>("AutoAdjustEnabledToggle");
87-
88-
8976
var triangleCountLabel = root.Q<IMGUIContainer>("TriangleCountLabel");
9077

9178
var removeInvalidEntriesButton = root.Q<Button>("RemoveInvalidEntriesButton");
@@ -102,7 +89,6 @@ public override VisualElement CreateInspectorGUI()
10289
{
10390
name = "Custom";
10491
}
105-
10692
targetTriangleCountPresetDropdownField.SetValueWithoutNotify(name);
10793
if (AutoAdjustEnabledProperty.boolValue)
10894
{
@@ -287,18 +273,22 @@ public override VisualElement CreateInspectorGUI()
287273

288274
return itemRoot;
289275
};
276+
277+
ndmfPreviewToggle.SetValueWithoutNotify(MeshiaCascadingAvatarMeshSimplifierPreview.PreviewControlNode.IsEnabled.Value);
290278
ndmfPreviewToggle.RegisterValueChangedCallback(changeEvent =>
291279
{
292280
MeshiaCascadingAvatarMeshSimplifierPreview.PreviewControlNode.IsEnabled.Value = changeEvent.newValue;
293281
});
294282

295-
ndmfPreviewToggle.SetValueWithoutNotify(MeshiaCascadingAvatarMeshSimplifierPreview.PreviewControlNode.IsEnabled.Value);
296-
onNdmfPreviewEnabledChanged = (newValue) =>
283+
Action<bool> onNdmfPreviewEnabledChanged = (newValue) =>
297284
{
298285
ndmfPreviewToggle.SetValueWithoutNotify(newValue);
299286
};
300287
MeshiaCascadingAvatarMeshSimplifierPreview.PreviewControlNode.IsEnabled.OnChange += onNdmfPreviewEnabledChanged;
301-
288+
ndmfPreviewToggle.RegisterCallback<DetachFromPanelEvent>(detachFromPanelEvent =>
289+
{
290+
MeshiaCascadingAvatarMeshSimplifierPreview.PreviewControlNode.IsEnabled.OnChange -= onNdmfPreviewEnabledChanged;
291+
});
302292

303293

304294
return root;

0 commit comments

Comments
 (0)