-
Notifications
You must be signed in to change notification settings - Fork 575
Description
Describe the bug
I was reading the documentation for Object Pooling since I wanted to add pooled bullet prefabs for my game, and it linked the source code for NetworkObjectPool.cs.
The code looked very strange to me as the pool is initialized only once, then never again. This leads me to believe it won't have correct behaviour if the server is shutdown, then started again for a 2nd time.
I don't know if this is proper Netcode for GameObjects style of coding, but anyway it does give me a KeyNotFoundException when trying to instantiate a pooled prefab when the server is started a 2nd time, because at that point, the _pooledObjects Dictionary has been cleared.
m_HasInitialized is never set back to false when ClearPool is called. Also the existing pooled prefabs don't seem to be cleaned up or reused properly after the server is started for a 2nd time.
I don't get why you have to unregister the prefab handlers anyway upon server shutdown. If the server program is about to exit, then it wouldn't matter since the entire program will close anyway. If the server is merely resetting itself, then wouldn't you want those prefab handlers to still be there?
I'm also confused why this is using its own queue instead of using the already existing ObjectPool class.
To Reproduce
Steps to reproduce the behavior:
- Go to '...'
- Click on '....'
- Scroll down to '....'
- See error
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Environment (please complete the following information):
- OS: Windows 10
- Unity Version: 2021.3.10f1
- BossRoom Version: n/a I got the NetworkObjectPool.cs from a link in the documentation.
Additional context
Add any other context about the problem here.