Edit:
I think i found the issue.
I registered the prefabs via ClientScene.RegisterPrefab after i registered the handlers with RegisterSpawnHandler. This seems to override the custom handlers.
It is also worth mentioning, that if the prefabs are registered in “Registered Spawnabler Prefabs” within the NetworkManager the custom spawn handlers are also overwritten.
Edit end.
.
Hello,
for each pool in my scene i register custom spawn handlers via:
foreach (KeyValuePair<string, ObjectPooler> entry in ObjectPoolerManager.Instance.objectPoolers) {
// registers the custom spawn and unSpawn handler for the client
// TODO: SpawnObject isn't called
ClientScene.RegisterSpawnHandler(entry.Value.assetId, entry.Value.SpawnObject, entry.Value.UnSpawnObject);
}
The UnSpawnObject method is called if i use NetworkServer.UnSpawn, but the SpawnObject method isn’t called if i use NetworkServer.Spawn.
public class ObjectPooler : MonoBehaviour {
...
public delegate void UnSpawnDelegate(GameObject spawned);
public delegate GameObject SpawnDelegate(Vector3 position, NetworkHash128 assetId);
// TODO: not called
public GameObject SpawnObject(Vector3 position, NetworkHash128 assetId) {
Debug.LogAssertion("Spawning object " + assetId);
return GetPooledObject();
}
public void UnSpawnObject(GameObject spawned) {
Debug.LogAssertion("Re-pooling object " + spawned.name);
spawned.SetActive(false);
}
....
}
Is this a known bug or do i miss something? i couldn’t find any information about this.
NetworkServer.Spawn is called from within a Command within the player controller.
Thx in advance!