-
Notifications
You must be signed in to change notification settings - Fork 455
feat: Added a way to safely access GlobalObjectIdHash via PrefabHashId [MTT-1645] #2437
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: Fatih Mar <[email protected]>
} | ||
} | ||
|
||
if ( NetworkManager.PrefabHandler.ContainsHandler( GlobalObjectIdHash ) ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The standards check issues are due to the 2 whitespaces on line 36 position 21 and line 36 position 67.
if (NetworkManager.PrefabHandler.ContainsHandler( GlobalObjectIdHash ))
👍
{ | ||
get | ||
{ | ||
foreach (var prefabList in NetworkManager.NetworkConfig.Prefabs.NetworkPrefabsLists) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we cache the result of this so it doesn't have to do this for-loop every time it's accessed? This seems like it would be pretty expensive, but as a property, it's not obvious that it's expensive to access.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we can unfortunately. I've added some tests and this code isn't correct. There is a Prefabs list in NetworkManager.NetworkConfig.Prefabs.Prefabs which is the actual list of prefabs we need to chefck against. NetworkPrefabsLists is just the list of saved prefabs, any prefabs added at runtime won't be considered. Since that list can change we can't rely on a cached value. Fortunately the use case for this is limited to the ConnectionApproval callback so its unlikely its going to get hit very often. I will update the PR soon with those changes.
and not the saved NetworkPrefabsLists as they opnly contain saved prefabs. Also removed checking the PrefabHandler as this isn't correct.
…tcode.gameobjects into MTT-5380
Added a way to access the GlobalObjectIdHash for use in ConnectionApproval callback. It checks the Object is actually a prefab before returning the value.
ConnectionApproval Runtime Determined GlobalObjectIdHash Spawn Not Possible [MTT-1645]
Changelog