feat: NetworkIdentity.isServer/ClientOnly added. NetworkBehaviour.isServer/ClientOnly uses it.

This commit is contained in:
vis2k 2021-02-18 14:24:15 +08:00
parent 4bef7fc635
commit 239bc660fd
2 changed files with 12 additions and 2 deletions

View File

@ -60,12 +60,12 @@ public abstract class NetworkBehaviour : MonoBehaviour
/// <summary>
/// True if this object only exists on the server
/// </summary>
public bool isServerOnly => isServer && !isClient;
public bool isServerOnly => netIdentity.isServerOnly;
/// <summary>
/// True if this object exists on a client that is not also acting as a server
/// </summary>
public bool isClientOnly => isClient && !isServer;
public bool isClientOnly => netIdentity.isClientOnly;
/// <summary>
/// This returns true if this object is the authoritative version of the object in the distributed network application.

View File

@ -162,6 +162,16 @@ public sealed class NetworkIdentity : MonoBehaviour
/// </summary>
public bool isLocalPlayer => ClientScene.localPlayer == this;
/// <summary>
/// True if this object only exists on the server
/// </summary>
public bool isServerOnly => isServer && !isClient;
/// <summary>
/// True if this object exists on a client that is not also acting as a server
/// </summary>
public bool isClientOnly => isClient && !isServer;
/// <summary>
/// This returns true if this object is the authoritative player object on the client.
/// <para>This value is determined at runtime. For most objects, authority is held by the server.</para>