private void Awake() { _buildingTypeList = Resources.Load <BuildingTypeListSo>(nameof(BuildingTypeListSo)); Transform buttonTemplate = transform.Find("buttonTemplate"); buttonTemplate.gameObject.SetActive(false); foreach (var buildingType in _buildingTypeList.list) { if (ignoreBuildingTypeList.Contains(buildingType)) { continue; } Transform buttonTransform = Instantiate(buttonTemplate, transform); buttonTransform.gameObject.SetActive(true); buttonTransform.Find("image").GetComponent <Image>().sprite = buildingType.sprite; buttonTransform.GetComponent <Button>().onClick.AddListener(() => { HandleSelectedButton(buildingType); }); AssignMouseEvents(buttonTransform, buildingType); _buttonTransformDictionary.Add(buildingType, buttonTransform); } }
private void Awake() { Instance = this; _buildingTypeList = Resources.Load <BuildingTypeListSo>(nameof(BuildingTypeListSo)); _activeBuildingType = null; }