Для режима уведомлений я пробовал использовать отправку сообщений, но не могу получить PlayerInput таким образом. , то же самое для событий Invoke Unity, но когда я пытаюсь использовать события Invoke C Sharp, я получаю эту ошибку: CS0123: Нет перегрузки для «OnPlayerJoined» соответствует делегату «Действие»
Вот соответствующее код в моем скрипте GameManager.
Код: Выделить всё
void Start()
{
PlayerInputManager.instance.JoinPlayer(0, -1, null);
PlayerInputManager.instance.JoinPlayer(1, -1, null);
}
void OnEnable()
{
// Throwing CS0123: No overload for 'OnPlayerJoined' matches delegate 'Action
'
//PlayerInputManager.instance.onPlayerJoined += OnPlayerJoined;
//PlayerInputManager.instance.onPlayerLeft += OnPlayerLeft;
}
void OnDisable()
{
//PlayerInputManager.instance.onPlayerJoined -= OnPlayerJoined;
//PlayerInputManager.instance.onPlayerLeft -= OnPlayerLeft;
}
public void OnPlayerJoined(PlayerInput playerInput)
{
Debug.Log("A player has joined!");
/*playerList.Add(playerInput);
if (PlayerJoinedGame != null)
{
PlayerJoinedGame(playerInput);
}*/
}
void OnPlayerLeft(PlayerInput playerInput)
{
Debug.Log("A player left the game.");
}
Изменить: я установил для своего актива InputActions имя PlayerInput. Изменение имени решило проблему, всем спасибо!
p.s. Я попытался отметить ответ, но, поскольку все ответы были комментариями, я не смог; спасибо hijinxbassist
Подробнее здесь: https://stackoverflow.com/questions/790 ... playerleft
Мобильная версия