mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
Made SetDynamicAssetId a setter on the assetId property. (#530)
* Made SetDynamicAssetId a setter on the assetId property. * Update NetworkIdentity.cs
This commit is contained in:
parent
c0ba0073b2
commit
8b2f99b3c4
@ -204,7 +204,7 @@ public static void RegisterPrefab(GameObject prefab, Guid newAssetId)
|
||||
NetworkIdentity identity = prefab.GetComponent<NetworkIdentity>();
|
||||
if (identity)
|
||||
{
|
||||
identity.SetDynamicAssetId(newAssetId);
|
||||
identity.assetId = newAssetId;
|
||||
|
||||
if (LogFilter.Debug) { Debug.Log("Registering prefab '" + prefab.name + "' as asset:" + identity.assetId); }
|
||||
prefabs[identity.assetId] = prefab;
|
||||
@ -424,7 +424,7 @@ internal static void OnSpawnPrefab(NetworkMessage netMsg)
|
||||
return;
|
||||
}
|
||||
localObject.Reset();
|
||||
localObject.SetDynamicAssetId(msg.assetId);
|
||||
localObject.assetId = msg.assetId;
|
||||
ApplySpawnPayload(localObject, msg.position, msg.rotation, msg.payload, msg.netId);
|
||||
}
|
||||
else
|
||||
|
@ -76,18 +76,14 @@ public Guid assetId
|
||||
// we would use 'new Guid("")'
|
||||
return string.IsNullOrEmpty(m_AssetId) ? Guid.Empty : new Guid(m_AssetId);
|
||||
}
|
||||
}
|
||||
|
||||
internal void SetDynamicAssetId(Guid newAssetId)
|
||||
{
|
||||
string newAssetIdString = newAssetId.ToString("N");
|
||||
if (string.IsNullOrEmpty(m_AssetId) || m_AssetId == newAssetIdString)
|
||||
internal set
|
||||
{
|
||||
m_AssetId = newAssetIdString;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("SetDynamicAssetId object already has an assetId <" + m_AssetId + ">");
|
||||
string newAssetIdString = value.ToString("N");
|
||||
if (string.IsNullOrEmpty(m_AssetId) || m_AssetId == newAssetIdString)
|
||||
{
|
||||
m_AssetId = newAssetIdString;
|
||||
}
|
||||
else Debug.LogWarning("SetDynamicAssetId object already has an assetId <" + m_AssetId + ">");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -478,7 +478,7 @@ public static bool ReplacePlayerForConnection(NetworkConnection conn, GameObject
|
||||
{
|
||||
if (GetNetworkIdentity(player, out NetworkIdentity identity))
|
||||
{
|
||||
identity.SetDynamicAssetId(assetId);
|
||||
identity.assetId = assetId;
|
||||
}
|
||||
return InternalReplacePlayerForConnection(conn, player);
|
||||
}
|
||||
@ -492,7 +492,7 @@ public static bool AddPlayerForConnection(NetworkConnection conn, GameObject pla
|
||||
{
|
||||
if (GetNetworkIdentity(player, out NetworkIdentity identity))
|
||||
{
|
||||
identity.SetDynamicAssetId(assetId);
|
||||
identity.assetId = assetId;
|
||||
}
|
||||
return InternalAddPlayerForConnection(conn, player);
|
||||
}
|
||||
@ -1011,7 +1011,7 @@ public static void Spawn(GameObject obj, Guid assetId)
|
||||
{
|
||||
if (GetNetworkIdentity(obj, out NetworkIdentity identity))
|
||||
{
|
||||
identity.SetDynamicAssetId(assetId);
|
||||
identity.assetId = assetId;
|
||||
}
|
||||
SpawnObject(obj);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user