With a custom spawn handler, the below function fails even with a registered prefab.
private NetworkIdentity OnClientSpawnCharacter(SpawnMessage msg)
{
if (!msg.PrefabHash.HasValue)
return null;
int prefabHash = msg.PrefabHash.Value;
SpawnHandler handler = clientObjectManager.GetSpawnHandler(prefabHash);
NetworkIdentity prefab = handler.Prefab;
var pos = msg.SpawnValues.Position ?? prefab.transform.position;
var rot = msg.SpawnValues.Rotation ?? prefab.transform.rotation;
return Instantiate(prefab, pos, rot);
}
This pull request adds the below constructors for SpawnHandler, which add the respective NetworkIdentity into the SpawnHandler so that the prefab can be found during spawn.
public SpawnHandler(NetworkIdentity prefab, SpawnHandlerDelegate spawnHandler, UnSpawnDelegate unspawnHandler);
public SpawnHandler(NetworkIdentity prefab, SpawnHandlerAsyncDelegate spawnHandlerAsync, UnSpawnDelegate unspawnHandler);
When registering a prefab with the below function, the resulting SpawnHandler has an empty
Prefab
.With a custom spawn handler, the below function fails even with a registered prefab.
This pull request adds the below constructors for SpawnHandler, which add the respective NetworkIdentity into the SpawnHandler so that the prefab can be found during spawn.