private void BuildField(UIField f, out float fieldHeight) { fieldHeight = 0f; if (f == null) { return; } string fieldTypeName = f.GetType().Name; int fieldPrefabIndex = Array.IndexOf(FieldTypeNames, fieldTypeName); UIFieldBuilder prefab = fieldPrefabIndex >= 0 && fieldPrefabIndex < fieldPrefabs.Length ? fieldPrefabs[fieldPrefabIndex] : null; if (prefab == null) { return; } UIFieldBuilder fieldInstance = Instantiate(prefab, fieldInstancesRoot); fieldInstance.CurrentField = f; fieldHeight = prefab.GetComponent <RectTransform>().rect.height; fieldInstances.Add(fieldInstance); }
private void Awake() { if (arrayRoot != null) { arrayContainer = arrayRoot.parent.GetComponent <RectTransform>(); UIFieldBuilder[] initInputs = arrayRoot.GetComponentsInChildren <UIFieldBuilder>(true); if (initInputs.Length > 0) { for (int i = 1, iend = initInputs.Length; i < iend; i++) { Destroy(initInputs[i].gameObject); } UIFieldBuilder inputModel = initInputs[0]; itemFieldBuilders = new List <UIFieldBuilder> { inputModel }; inputModel.gameObject.SetActive(false); fieldHeight = inputModel.GetComponent <RectTransform>().rect.height; } minScrollY = arrayRoot.anchoredPosition.y; } if (removeItemButton != null) { accurateRemoveItemButton = removeItemButton.GetComponent <UIAccurateButton>(); removeItemButton.interactable = false; } if (upButton != null) { accurateUpButton = upButton.GetComponent <UIAccurateButton>(); upButton.interactable = false; } if (downButton != null) { accurateDownButton = downButton.GetComponent <UIAccurateButton>(); downButton.interactable = false; } }