feat: update transform sync settings#290
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors network synchronization settings to improve encapsulation and Unity Editor usability. The changes convert public fields to private serialized fields with public properties, add tooltips and validation attributes, and enhance the Inspector UI presentation of these advanced settings.
Changes:
- Refactored
ServerDiscoveryPortand transform send rate from public fields to private serialized fields with public property accessors - Enhanced Unity Inspector UI with custom labels and improved organization in the Advanced Options section
- Removed unused
_sendRatefield to eliminate code redundancy
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| NetSyncManager.cs | Converted public fields to private serialized fields with properties, added validation attributes, removed unused field, and fixed trailing whitespace |
| NetSyncManagerEditor.cs | Updated advanced properties list to reference new field names and added custom label for transform send rate display |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
STYLY-NetSync-Unity/Packages/com.styly.styly-netsync/Runtime/NetSyncManager.cs
Show resolved
Hide resolved
… and update related documentation
|
@claude Review the latest code. |
|
Claude finished @from2001's task in 1m 33s —— View job Code Review Complete ✓Reviewing PR #290: feat: update transform sync settings SummaryThis PR successfully refactors network synchronization settings to improve encapsulation and Unity Editor usability. The changes are well-structured and maintain consistency between the Unity client and Python server. However, there are a few issues that need to be addressed. Issues Found🔴 Critical Issue: Missing Property Setter ValidationFile: The public int ServerDiscoveryPort
{
get => _serverDiscoveryPort;
set => _serverDiscoveryPort = value; // ❌ No validation, no propagation
}Impact:
Recommendation: Add validation matching the field attribute and propagate to the discovery manager: public int ServerDiscoveryPort
{
get => _serverDiscoveryPort;
set
{
var clamped = Mathf.Max(1, value);
if (_serverDiscoveryPort == clamped)
{
return;
}
_serverDiscoveryPort = clamped;
if (_discoveryManager != null)
{
_discoveryManager.Port = _serverDiscoveryPort;
}
}
}Note: The copilot reviewer also identified this same issue.
|
…tion and related tests
This pull request refactors and improves the configuration of advanced network synchronization settings in the NetSync system. The main changes include making the transform send rate and server discovery port private serialized fields with proper tooltips and ranges, exposing them through public properties, and enhancing their presentation in the Unity Editor. These updates improve encapsulation, maintainability, and user experience when configuring network sync settings.
Advanced Settings Refactor and Editor Improvements:
ServerDiscoveryPortand transform send rate from public fields to private serialized fields (_serverDiscoveryPort,_transformSendRate) with appropriate[SerializeField], range, and tooltip attributes for better encapsulation and Inspector usability.ServerDiscoveryPortandTransformSendRate, including value clamping and integration with the internalTransformSyncManagerfor dynamic updates.TransformSyncManagerto use the new_transformSendRatefield instead of the previous_sendRate.Unity Editor Usability Enhancements:
NetSyncManagerEditorto display the new_transformSendRateand_serverDiscoveryPortfields in the advanced section, including a custom label for the transform send rate for clarity. [1] [2]Code Cleanup:
_sendRatefield fromNetSyncManagerto avoid confusion and redundancy.