using FishNet.Broadcast; using FishNet.Managing; using FishNet.Transporting; using UnityEngine; namespace FishNet.Object { public sealed partial class NetworkObject : MonoBehaviour { /// /// Sends a broadcast to Observers on this NetworkObject. /// /// Type of broadcast to send. /// Broadcast data being sent; for example: an instance of your broadcast type. /// True if the client must be authenticated for this broadcast to send. /// Channel to send on. public void Broadcast(T message, bool requireAuthenticated = true, Channel channel = Channel.Reliable) where T : struct, IBroadcast { if (NetworkManager == null) { NetworkManager.StaticLogWarning($"Cannot send broadcast from {gameObject.name}, NetworkManager reference is null. This may occur if the object is not spawned or initialized."); return; } NetworkManager.ServerManager.Broadcast(Observers, message, requireAuthenticated, channel); } } }