using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.InputSystem; [RequireComponent(typeof(PlayerInputManager))] public class PlayerManager : MonoBehaviour { [SerializeField] private PlayerList m_connectedPlayers; private PlayerInputManager m_playerManager; private void OnEnable() { DontDestroyOnLoad(gameObject); m_playerManager = GetComponent(); } public void OnPlayerJoined(UnityEngine.InputSystem.PlayerInput player) { GameObject newPlayer = player.gameObject; Debug.Log($"New Player Joined"); PlayerData data = m_connectedPlayers.AddPlayer(player); newPlayer.GetComponent().Initialise(data); newPlayer.transform.SetParent(transform, false); } public void AllowJoin(bool value) { if (value) m_playerManager.EnableJoining(); else m_playerManager.DisableJoining(); } }