using System.Collections.Generic; using UnityEngine; using UnityEngine.InputSystem; using Random = UnityEngine.Random; public class Lobby : MonoBehaviour { [SerializeField] List players; void Awake() => players = new List(); public void OnPlayerJoined(PlayerInput playerInput) { playerInput.transform.parent = transform; players.Add(playerInput.GetComponent()); playerInput.gameObject.name = "Player " + players.Count; Debug.Log(playerInput.gameObject.name + " joined!"); var color = Random.ColorHSV(0, 1, 0.8f, 1, 0.8f, 1); playerInput.GetComponent().material .color = color; float h, s, v; Color.RGBToHSV(color, out h, out s, out v); playerInput.transform.GetChild(0).GetComponent().material .color = Color.HSVToRGB((h - 0.05f) % 1f, s + 0.05f, v - 0.1f); } public void OnPlayerLeft(PlayerInput playerInput) => Debug.Log(playerInput.gameObject.name + " left :O"); }