using System; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; public class FacilityUIPowerUpMaterialList : MonoBehaviour { private FacilityManager FacilityMgr { get { if (this.m_FacilityMgr == null) { this.m_FacilityMgr = GameMain.Instance.FacilityMgr; } return this.m_FacilityMgr; } } public void Show(int id, Facility facility, Action callbackSelect) { this.m_CallbackSelect = callbackSelect; this.SetupFacilityPowerUpMaterialListDropDown(id, facility); } private void SetupFacilityPowerUpMaterialListDropDown(int id, Facility facility) { this.m_uGUIListViewer.parentItemArea.gameObject.SetActive(true); this.DeleteDropdown(); Facility.PowerUpRecipe facilityPowerUpRecipe = FacilityDataTable.GetFacilityPowerUpRecipe(id); int[] materialCategoryIDArray = facilityPowerUpRecipe.materialCategoryIDArray; Facility.RecipeData recipeData = facility.GetRecipeData(id); this.m_uGUIListViewer.Show(materialCategoryIDArray.Length, delegate(int i, Transform trans) { int num = materialCategoryIDArray[i]; Dropdown componentInChildren = trans.GetComponentInChildren(); Text[] componentsInChildren = trans.GetComponentsInChildren(); FacilityUIPowerUpMaterialList.DropdownPowerUpMaterial dropdownPowerUpMaterial = trans.gameObject.AddComponent(); string facilityPowerUpMaterialCategoryName = FacilityDataTable.GetFacilityPowerUpMaterialCategoryName(num); componentsInChildren[0].text = facilityPowerUpMaterialCategoryName; componentsInChildren[1].text = string.Format("CATEGORY{0}", i + 1); componentInChildren.ClearOptions(); Facility.PowerUpMaterial[] materialArray = this.FacilityMgr.GetFacilityPowerUpItemEnableArray(num); if (materialArray.Length > 0) { for (int j = 0; j < materialArray.Length; j++) { componentInChildren.options.Add(new Dropdown.OptionData(materialArray[j].name)); if (recipeData.materialIDArray[i] == materialArray[j].id) { dropdownPowerUpMaterial.materialID = materialArray[j].id; componentInChildren.value = j; } } } else { componentInChildren.image.raycastTarget = false; dropdownPowerUpMaterial.materialID = 0; componentInChildren.options.Add(new Dropdown.OptionData("無し")); } if (dropdownPowerUpMaterial.materialID == 0) { if (materialArray.Length > 0) { dropdownPowerUpMaterial.materialID = materialArray[0].id; componentInChildren.value = 0; } else { dropdownPowerUpMaterial.materialID = -1; } } componentInChildren.RefreshShownValue(); componentInChildren.onValueChanged.AddListener(delegate(int value) { dropdownPowerUpMaterial.materialID = materialArray[value].id; this.OnUpdateDropdownParams(); }); if (i == 0) { Transform transform = dropdownPowerUpMaterial.transform.Find("Image Plus Mark"); if (transform) { transform.gameObject.SetActive(false); } else { Debug.LogError("[FacilityPowerUP]プラスマークのイメージが見つかりません\n「Image Plus Mark」という名前の子オブジェクトを追加してください"); } } }); this.OnUpdateDropdownParams(); } public void HideAllDropdown() { Transform transform = this.m_uGUIListViewer.transform; Dropdown[] componentsInChildren = transform.GetComponentsInChildren(); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].Hide(); } } public void DeleteDropdown() { this.HideAllDropdown(); this.m_uGUIListViewer.ResetList(); } private void OnUpdateDropdownParams() { Transform transform = this.m_uGUIListViewer.transform; FacilityUIPowerUpMaterialList.DropdownPowerUpMaterial[] componentsInChildren = transform.GetComponentsInChildren(); int[] array = new int[componentsInChildren.Length]; for (int i = 0; i < componentsInChildren.Length; i++) { array[i] = componentsInChildren[i].materialID; } if (this.m_CallbackSelect != null) { this.m_CallbackSelect(array); } } private FacilityManager m_FacilityMgr; [SerializeField] private uGUIListViewer m_uGUIListViewer; private Action m_CallbackSelect; private class DropdownPowerUpMaterial : MonoBehaviour, IPointerClickHandler, ISubmitHandler, IEventSystemHandler { private void SetupTemplateCanvas() { Dropdown component = base.GetComponent(); Transform transform = component.transform.Find("Dropdown List"); if (!transform) { return; } Canvas component2 = transform.GetComponent(); Canvas componentInParent = component.GetComponentInParent(); component2.sortingOrder = componentInParent.sortingOrder + 50; } private void SetupBlockerCanvas() { Dropdown component = base.GetComponent(); Canvas componentInParent = component.GetComponentInParent(); Transform transform = componentInParent.transform.Find("Blocker"); if (!transform) { return; } Canvas component2 = transform.GetComponent(); component2.sortingOrder = componentInParent.sortingOrder + 1; CanvasGroup canvasGroup = transform.gameObject.GetComponent(); if (!canvasGroup) { canvasGroup = transform.gameObject.AddComponent(); } canvasGroup.ignoreParentGroups = true; canvasGroup.interactable = true; canvasGroup.blocksRaycasts = true; } public void OnPointerClick(PointerEventData data) { this.SetupTemplateCanvas(); this.SetupBlockerCanvas(); } public void OnSubmit(BaseEventData data) { this.SetupTemplateCanvas(); this.SetupBlockerCanvas(); } public int materialID; } }