feat: Added a way to safely access GlobalObjectIdHash via PrefabHashId [MTT-1645]#2437
feat: Added a way to safely access GlobalObjectIdHash via PrefabHashId [MTT-1645]#2437NoelStephensUnity merged 17 commits intodevelopfrom
Conversation
Co-authored-by: Fatih Mar <mfatihmar@gmail.com>
| } | ||
| } | ||
|
|
||
| if ( NetworkManager.PrefabHandler.ContainsHandler( GlobalObjectIdHash ) ) |
There was a problem hiding this comment.
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.
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.
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