feat: Add optional defaultValue parameter to GetGlobalVariable#12
feat: Add optional defaultValue parameter to GetGlobalVariable#12
Conversation
- Add overloaded method GetGlobalVariable(string name, string defaultValue = null) - Implemented in both NetSyncManager and NetworkVariableManager - Maintains backward compatibility with existing method signature - Returns defaultValue when variable doesn't exist in global variables Resolves #7 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Masahiro Yamaguchi <from2001@users.noreply.github.com>
|
@claude |
|
Claude finished @from2001's task —— View job ✅ Implementation completed successfully! Todo List
Changes MadeAdded NetworkVariableManager.cs (lines 141-148)public string GetClientVariable(int clientNo, string name, string defaultValue = null)
{
if (_clientVariables.TryGetValue(clientNo, out var clientVars))
{
return clientVars.TryGetValue(name, out var value) ? value : defaultValue;
}
return defaultValue;
}NetSyncManager.cs (lines 109-112)public string GetClientVariable(int clientNo, string name, string defaultValue = null)
{
return _networkVariableManager?.GetClientVariable(clientNo, name, defaultValue) ?? defaultValue;
}NetSyncAvatar.cs (lines 355-358, 379-382)
Key Features
The implementation returns the |
- Added overloaded GetClientVariable(int clientNo, string name, string defaultValue) to NetworkVariableManager - Added overloaded GetClientVariable(int clientNo, string name, string defaultValue) to NetSyncManager - Added overloaded GetClientVariable(string name, string defaultValue) and GetClientVariable(int clientNo, string name, string defaultValue) to NetSyncAvatar - Maintains backward compatibility with existing method signatures - Follows same pattern as GetGlobalVariable with defaultValue parameter 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Masahiro Yamaguchi <from2001@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
This PR adds optional default value support to variable getter methods in the NetSync system. The changes provide fallback values when requested variables don't exist, improving the robustness of variable access patterns.
- Adds overloaded methods with
defaultValueparameters toGetGlobalVariableandGetClientVariablemethods - Implements the feature across all relevant classes in the NetSync hierarchy
- Maintains backward compatibility with existing method signatures
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| NetSyncManager.cs | Adds overloaded methods for getting global and client variables with default values |
| NetSyncAvatar.cs | Extends client variable getter methods to support default values with documentation |
| NetworkVariableManager.cs | Implements core logic for default value handling in the underlying variable storage |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
STYLY-NetSync-Unity/Packages/com.styly.styly-netsync/Runtime/NetSyncManager.cs
Outdated
Show resolved
Hide resolved
STYLY-NetSync-Unity/Packages/com.styly.styly-netsync/Runtime/NetSyncManager.cs
Outdated
Show resolved
Hide resolved
STYLY-NetSync-Unity/Packages/com.styly.styly-netsync/Runtime/NetSyncAvatar.cs
Outdated
Show resolved
Hide resolved
STYLY-NetSync-Unity/Packages/com.styly.styly-netsync/Runtime/NetSyncAvatar.cs
Outdated
Show resolved
Hide resolved
…etSyncManager.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…etSyncManager.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…etSyncAvatar.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…etSyncAvatar.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@claude |
|
Claude finished @from2001's task —— View job Todo List
Refactoring Complete!Successfully refactored the code to use default parameters instead of overloaded methods: Changes MadeNetworkVariableManager.cs:
NetSyncManager.cs:
NetSyncAvatar.cs:
Benefits
The refactored code maintains the same functionality while providing a simpler, more maintainable API. |
…t*Variable - Removed overloaded methods and added default parameters to existing methods - Eliminated redundant null-coalescing operators as suggested in review - Maintains backward compatibility while simplifying the API Co-authored-by: Masahiro Yamaguchi <from2001@users.noreply.github.com>
|
LGTM |
Add overloaded method GetGlobalVariable(string name, string defaultValue = null)
Resolves #7
🤖 Generated with Claude Code