18 lines
498 B
C#

using UnityEngine;
using UnityEngine.InputSystem;
[RequireComponent(typeof(PlayerInput))]
public class Player : MonoBehaviour {
public GameObject labelPrefab;
void Start() {
Transform canvas = GameObject.Find("Canvas").transform;
PlayerLabel label = Instantiate(labelPrefab, canvas).GetComponent<PlayerLabel>();
var playerInput = GetComponent<PlayerInput>();
label.player = transform;
label.SetName(gameObject.name);
label.SetController(playerInput.currentControlScheme);
}
}