25 lines
611 B
C#
25 lines
611 B
C#
using Fusion;
|
|
using UnityEngine;
|
|
|
|
[RequireComponent(typeof(NetworkObject))]
|
|
public class PlayerCameraSetup : NetworkBehaviour
|
|
{
|
|
[Tooltip("Drag your MainCamera child here")]
|
|
[SerializeField] Camera playerCamera;
|
|
|
|
[Tooltip("If you have an AudioListener on that camera")]
|
|
[SerializeField] AudioListener audioListener;
|
|
|
|
public override void Spawned()
|
|
{
|
|
base.Spawned();
|
|
|
|
bool isMine = Object.HasInputAuthority;
|
|
|
|
if (playerCamera != null)
|
|
playerCamera.enabled = isMine;
|
|
if (audioListener != null)
|
|
audioListener.enabled = isMine;
|
|
}
|
|
}
|