private void buttonClick() { if (selectButtonPanel.getButtonActive()) { if (currentSelectedGameObject.name == "EquipmentSelectedButton") { //装备按钮 enterEquipmentPanel(); } else if (currentSelectedGameObject.name == "SkillsSelectedButton") { //技能按钮 enterSkillsPanel(); } } else if (equipmentPanel.getButtonActive()) { var index = currentSelectedGameObject.getButton().siblingButtonIndex; var controller = EquipmentListViewController.Create(); controller.type = ItemsListType.equipment; controller.clickAction = (MMX.Item item) => { Debug.Log(index); setEquipment(item as MMX.HumanEquipment, index); }; controller.show(); } }
public override void Awake() { base.Awake(); inputs.UI.A.performed += ctx => { var index = EventSystem.current.currentSelectedGameObject.transform.GetSiblingIndex(); if (index >= 0 && index < 3) { var controller = ItemsListViewController.Create(); controller.type = (ItemsListType)index; controller.show(); } else if (index == 3) { EquipmentListViewController.Create().show(); } }; inputs.UI.B.performed += ctx => hide(); Dictionary <int, VehicleInfo> vehicles = new Dictionary <int, VehicleInfo>(); for (var index = 0; index < TeamQueue.shared.humans.Count; index++) { var human = TeamQueue.shared.humans[index].GetComponent <HumanInfo>(); var vehicle = human.currentTakedVehicle; if (vehicle != null && !vehicles.ContainsValue(vehicle)) { vehicles.Add(index, vehicle); } } var vehiclePanel = gameObject.FindComponentByObjectName <RectTransform>("Vehicle"); for (int i = 0; i < 4; i++) { var vehicleButton = vehiclePanel.GetChild(i); if (vehicles.ContainsKey(i)) { var vehicle = vehicles[i]; vehicleButton.gameObject.FindComponentByObjectName <UnityEngine.UI.Image>("Image").sprite = vehicle.avatar; vehicleButton.gameObject.FindComponentByObjectName <UnityEngine.UI.Text>("Text").text = vehicle.name; } else { vehicleButton.gameObject.GetComponent <CanvasGroup>().alpha = 0; vehicleButton.gameObject.GetComponent <CanvasGroup>().interactable = false; vehicleButton.gameObject.GetComponent <CanvasGroup>().blocksRaycasts = false; } } if (vehicles.Count <= 0) { Destroy(vehiclePanel.gameObject); } }