#if MIRROR using System.Collections; using System.Collections.Generic; using UnityEngine; using Mirror; namespace BITKit { public class NetworkAudioSource : NetworkBehaviour { [Header(Constant.Header.Components)] public AudioSource audioSource; [Header(Constant.Header.InternalVariables)] IGenericEvent genericEvent; public void Play(AudioSO so) { if (isOwned) CmdPlay(so); else if (isServer) RpcPlay(so); } void Start() { TryGetComponent>(out genericEvent); } [Command] void CmdPlay(AudioSO so) { RpcPlay(so); } [ClientRpc] void RpcPlay(AudioSO so) { audioSource.loop = so.loop; audioSource.clip = so.Get(); audioSource.Play(); if (genericEvent is not null) { genericEvent.Invoke(so); } } } } #endif