mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
syntax
This commit is contained in:
parent
89df32563b
commit
a643cf7045
@ -932,31 +932,31 @@ static NetworkIdentity GetExistingObject(uint netid)
|
|||||||
return localObject;
|
return localObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
static NetworkIdentity SpawnPrefab(SpawnMessage msg)
|
static NetworkIdentity SpawnPrefab(SpawnMessage message)
|
||||||
{
|
{
|
||||||
if (GetPrefab(msg.assetId, out GameObject prefab))
|
if (GetPrefab(message.assetId, out GameObject prefab))
|
||||||
{
|
{
|
||||||
GameObject obj = GameObject.Instantiate(prefab, msg.position, msg.rotation);
|
GameObject obj = GameObject.Instantiate(prefab, message.position, message.rotation);
|
||||||
//Debug.Log("Client spawn handler instantiating [netId:" + msg.netId + " asset ID:" + msg.assetId + " pos:" + msg.position + " rotation: " + msg.rotation + "]");
|
//Debug.Log("Client spawn handler instantiating [netId:" + msg.netId + " asset ID:" + msg.assetId + " pos:" + msg.position + " rotation: " + msg.rotation + "]");
|
||||||
return obj.GetComponent<NetworkIdentity>();
|
return obj.GetComponent<NetworkIdentity>();
|
||||||
}
|
}
|
||||||
if (spawnHandlers.TryGetValue(msg.assetId, out SpawnHandlerDelegate handler))
|
if (spawnHandlers.TryGetValue(message.assetId, out SpawnHandlerDelegate handler))
|
||||||
{
|
{
|
||||||
GameObject obj = handler(msg);
|
GameObject obj = handler(message);
|
||||||
if (obj == null)
|
if (obj == null)
|
||||||
{
|
{
|
||||||
Debug.LogError($"Spawn Handler returned null, Handler assetId '{msg.assetId}'");
|
Debug.LogError($"Spawn Handler returned null, Handler assetId '{message.assetId}'");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
NetworkIdentity identity = obj.GetComponent<NetworkIdentity>();
|
NetworkIdentity identity = obj.GetComponent<NetworkIdentity>();
|
||||||
if (identity == null)
|
if (identity == null)
|
||||||
{
|
{
|
||||||
Debug.LogError($"Object Spawned by handler did not have a NetworkIdentity, Handler assetId '{msg.assetId}'");
|
Debug.LogError($"Object Spawned by handler did not have a NetworkIdentity, Handler assetId '{message.assetId}'");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return identity;
|
return identity;
|
||||||
}
|
}
|
||||||
Debug.LogError($"Failed to spawn server object, did you forget to add it to the NetworkManager? assetId={msg.assetId} netId={msg.netId}");
|
Debug.LogError($"Failed to spawn server object, did you forget to add it to the NetworkManager? assetId={message.assetId} netId={message.netId}");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user