mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
NetworkIdentity.passive
This commit is contained in:
parent
9d0e90f484
commit
49228d59e9
@ -40,6 +40,9 @@ public struct NetworkIdentitySerialization
|
||||
[HelpURL("https://mirror-networking.gitbook.io/docs/components/network-identity")]
|
||||
public sealed class NetworkIdentity : MonoBehaviour
|
||||
{
|
||||
[Tooltip("Performance optimization for passive objects like Npcs, ItemDrops, Trees, Structures etc. skip broadcasting.\nPassive objects only spawn and despawn, their state isn't synced.\nThis can make a huge performance difference for large worlds with lots of passive objects.")]
|
||||
public bool passive = false;
|
||||
|
||||
/// <summary>Returns true if running as a client and this object was spawned by a server.</summary>
|
||||
//
|
||||
// IMPORTANT:
|
||||
|
@ -1667,6 +1667,8 @@ static void BroadcastToConnection(NetworkConnectionToClient connection)
|
||||
// NetworkServer.Destroy)
|
||||
if (identity != null)
|
||||
{
|
||||
if (identity.passive) continue;
|
||||
|
||||
// get serialization for this entity viewed by this connection
|
||||
// (if anything was serialized this time)
|
||||
NetworkWriter serialization = SerializeForConnection(identity, connection);
|
||||
|
@ -26,6 +26,8 @@ public override void OnStartServer()
|
||||
// color coding
|
||||
// can't do this in update, it's too expensive
|
||||
rend.material.color = sleeping ? sleepingColor : activeColor;
|
||||
|
||||
netIdentity.passive = sleeping;
|
||||
}
|
||||
|
||||
[ServerCallback]
|
||||
|
Loading…
Reference in New Issue
Block a user