void RecyclingContainer_OnDataSet(RecyclingButton recyclingButton) { CustomButton customButton = recyclingButton.GetComponent <CustomButton>(); if (customButton != null) { CustomDataSample customData = null; if (customDataDictionary.TryGetValue(recyclingButton.Model.Id, out customData)) { customButton.OtherLabel.text = customData.CustomLabel; } } }
private void FillPrefabs() { for (int i = 0; i < _PrefabCount - 1; i++) { RecyclingButton newTextButton = Instantiate(PrefabButton, _ContainerRT); RectTransform rt = newTextButton.GetComponent <RectTransform>(); rt.localScale = PrefabRT.localScale; rt.sizeDelta = PrefabRT.sizeDelta; rt.transform.position = PrefabRT.transform.position; rt.anchoredPosition = new Vector2(0, (i + 1) * -PrefabRT.sizeDelta.y); Buttons.Add(newTextButton); } }
private void RestackButtons(int index, int dataIndex) { int itButtons = 0; int currentButtonIndex = index; while (itButtons < Buttons.Count) { if (currentButtonIndex > Buttons.Count - 1) { currentButtonIndex = 0; } RecyclingButton currentButton = Buttons[currentButtonIndex]; // set visible if (dataIndex < _DataCount) { currentButton.gameObject.SetActive(true); // set position RectTransform currentButtonRT = currentButton.GetComponent <RectTransform>(); currentButtonRT.localPosition = new Vector3( currentButtonRT.localPosition.x, (-itButtons * PrefabRT.sizeDelta.y) + (-_TopIndex * PrefabRT.sizeDelta.y), currentButtonRT.localPosition.z); // set content SetButtonContent(currentButton, dataIndex); } else { currentButton.gameObject.SetActive(false); } currentButtonIndex++; dataIndex++; itButtons++; } }
private void GetPrefab() { PrefabButton = GetComponentInChildren <RecyclingButton>(); PrefabRT = PrefabButton.GetComponent <RectTransform>(); Buttons.Add(PrefabButton); }