diff --git a/com.unity.netcode.gameobjects/CHANGELOG.md b/com.unity.netcode.gameobjects/CHANGELOG.md index 2eb3776c3b..36cfd1f7a2 100644 --- a/com.unity.netcode.gameobjects/CHANGELOG.md +++ b/com.unity.netcode.gameobjects/CHANGELOG.md @@ -24,6 +24,8 @@ Additional documentation and release notes are available at [Multiplayer Documen ### Fixed +- Fixed issue where the `Axis to Synchronize` toggles didn't work with multi object editing in `NetworkTransform`. (#3781) + ### Security diff --git a/com.unity.netcode.gameobjects/Editor/NetworkTransformEditor.cs b/com.unity.netcode.gameobjects/Editor/NetworkTransformEditor.cs index 5c79b48e81..b5def1f138 100644 --- a/com.unity.netcode.gameobjects/Editor/NetworkTransformEditor.cs +++ b/com.unity.netcode.gameobjects/Editor/NetworkTransformEditor.cs @@ -107,11 +107,11 @@ private void DisplayNetworkTransformProperties() rect = EditorGUI.PrefixLabel(rect, ctid, s_PositionLabel); rect.width = s_ToggleOffset; - m_SyncPositionXProperty.boolValue = EditorGUI.ToggleLeft(rect, "X", m_SyncPositionXProperty.boolValue); + DrawToggleProperty(rect, "X", m_SyncPositionXProperty); rect.x += s_ToggleOffset; - m_SyncPositionYProperty.boolValue = EditorGUI.ToggleLeft(rect, "Y", m_SyncPositionYProperty.boolValue); + DrawToggleProperty(rect, "Y", m_SyncPositionYProperty); rect.x += s_ToggleOffset; - m_SyncPositionZProperty.boolValue = EditorGUI.ToggleLeft(rect, "Z", m_SyncPositionZProperty.boolValue); + DrawToggleProperty(rect, "Z", m_SyncPositionZProperty); GUILayout.EndHorizontal(); } @@ -126,11 +126,11 @@ private void DisplayNetworkTransformProperties() rect = EditorGUI.PrefixLabel(rect, ctid, s_RotationLabel); rect.width = s_ToggleOffset; - m_SyncRotationXProperty.boolValue = EditorGUI.ToggleLeft(rect, "X", m_SyncRotationXProperty.boolValue); + DrawToggleProperty(rect, "X", m_SyncRotationXProperty); rect.x += s_ToggleOffset; - m_SyncRotationYProperty.boolValue = EditorGUI.ToggleLeft(rect, "Y", m_SyncRotationYProperty.boolValue); + DrawToggleProperty(rect, "Y", m_SyncRotationYProperty); rect.x += s_ToggleOffset; - m_SyncRotationZProperty.boolValue = EditorGUI.ToggleLeft(rect, "Z", m_SyncRotationZProperty.boolValue); + DrawToggleProperty(rect, "Z", m_SyncRotationZProperty); GUILayout.EndHorizontal(); } @@ -150,11 +150,11 @@ private void DisplayNetworkTransformProperties() rect = EditorGUI.PrefixLabel(rect, ctid, s_ScaleLabel); rect.width = s_ToggleOffset; - m_SyncScaleXProperty.boolValue = EditorGUI.ToggleLeft(rect, "X", m_SyncScaleXProperty.boolValue); + DrawToggleProperty(rect, "X", m_SyncScaleXProperty); rect.x += s_ToggleOffset; - m_SyncScaleYProperty.boolValue = EditorGUI.ToggleLeft(rect, "Y", m_SyncScaleYProperty.boolValue); + DrawToggleProperty(rect, "Y", m_SyncScaleYProperty); rect.x += s_ToggleOffset; - m_SyncScaleZProperty.boolValue = EditorGUI.ToggleLeft(rect, "Z", m_SyncScaleZProperty.boolValue); + DrawToggleProperty(rect, "Z", m_SyncScaleZProperty); GUILayout.EndHorizontal(); } @@ -281,6 +281,28 @@ private void DisplayNetworkTransformProperties() #endif // COM_UNITY_MODULES_PHYSICS2D } + /// + /// Draw a ToggleLeft property field so it will support multi selection editing if applicable. + /// + private void DrawToggleProperty(Rect rect, string label, SerializedProperty property) + { + if (property.hasMultipleDifferentValues) + { + EditorGUI.showMixedValue = true; + EditorGUI.BeginChangeCheck(); + bool enabled = EditorGUI.ToggleLeft(rect, label, property.boolValue); + if (EditorGUI.EndChangeCheck()) + { + property.boolValue = enabled; + } + EditorGUI.showMixedValue = false; + } + else + { + property.boolValue = EditorGUI.ToggleLeft(rect, label, property.boolValue); + } + } + /// public override void OnInspectorGUI() {