Skip to content

Commit

Permalink
remove serverOnly (#496)
Browse files Browse the repository at this point in the history
As discussed in discord,  removing this flag.
Changing this flag at runtime does not work at all.
and it is also bugged,  see #389

The use case this addresses is to have an object that only lives in the server
but you can easily achieve this by setting an object as active
in the Started and Stopped events in NetworkServer.

In the future, we may reintroduce this if there is a good case for it
with an AOI rewrite

closes #389

BREAKING CHANGE: Remove serverOnly option in NetworkIdentity
  • Loading branch information
paulpach committed Dec 19, 2020
1 parent 78e6077 commit 0ef5c33
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 10 deletions.
8 changes: 1 addition & 7 deletions Assets/Mirror/Runtime/NetworkIdentity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public sealed class NetworkIdentity : MonoBehaviour
/// <summary>
/// Returns true if running as a client and this object was spawned by a server.
/// </summary>
public bool IsClient => Client != null && Client.Active && NetId != 0 && !serverOnly;
public bool IsClient => Client != null && Client.Active && NetId != 0;

/// <summary>
/// Returns true if NetworkServer.active and server is not stopped.
Expand Down Expand Up @@ -157,12 +157,6 @@ public sealed class NetworkIdentity : MonoBehaviour
[FormerlySerializedAs("m_SceneId"), HideInInspector]
public ulong sceneId;

/// <summary>
/// Flag to make this object only exist when the game is running as a server (or host).
/// </summary>
[FormerlySerializedAs("m_ServerOnly")]
public bool serverOnly;

/// <summary>
/// The NetworkServer associated with this NetworkIdentity.
/// </summary>
Expand Down
3 changes: 0 additions & 3 deletions Assets/Mirror/Runtime/ServerObjectManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -424,9 +424,6 @@ internal void SpawnObject(GameObject obj, INetworkConnection ownerConnection)

internal void SendSpawnMessage(NetworkIdentity identity, INetworkConnection conn)
{
if (identity.serverOnly)
return;

// for easier debugging
if (logger.LogEnabled()) logger.Log("Server SendSpawnMessage: name=" + identity.name + " sceneId=" + identity.sceneId.ToString("X") + " netid=" + identity.NetId);

Expand Down

0 comments on commit 0ef5c33

Please sign in to comment.