此示例项目是为了演示 Unity 输入系统的各种工具和功能。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

49 行
1.6 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Utilities;
public class UIMenuManager : Singleton<UIMenuManager>
{
[Header("References")]
public GameObject UIMenuCameraObject;
[Header("In-Scene Player Panel")]
public GameObject inScenePlayerRebindPanel;
[Header("Player Panel Settings")]
public GameObject playerRebindPanelPrefab;
public Transform playerRebindListRoot;
public void UpdateRebindPlayerPanelList()
{
Destroy(inScenePlayerRebindPanel);
List<PlayerController> activePlayerControllers = GameManager.Instance.GetActivePlayerControllers();
for(int i = 0; i < activePlayerControllers.Count; i++)
{
GameObject spawnedPlayerRebindPanel = Instantiate(playerRebindPanelPrefab, playerRebindListRoot.position, playerRebindListRoot.rotation) as GameObject;
spawnedPlayerRebindPanel.transform.SetParent(playerRebindListRoot, false);
PlayerInput spawnedPlayerInput = activePlayerControllers[i].GetPlayerInput();
int spawnedPlayerIndex = spawnedPlayerInput.playerIndex;
string spawnedPlayerDevicePath = spawnedPlayerInput.devices[0].ToString();
spawnedPlayerRebindPanel.GetComponent<UIPlayerRebindDisplayBehaviour>().SetupPanelDisplays(spawnedPlayerIndex, spawnedPlayerDevicePath);
}
}
public void ToggleMenu(bool newState)
{
UIMenuCameraObject.SetActive(newState);
}
}