public static CUIDropdown Create(CUIPanel oCanvas, CProp oProp, FieldInfo[] aFieldsEnum) { GameObject oDropdownResGO = Resources.Load("UI/CUIDropdown") as GameObject; GameObject oDropdownGO = Instantiate(oDropdownResGO) as GameObject; oDropdownGO.transform.SetParent(oCanvas.transform, false); CUIDropdown oUIDropdown = oDropdownGO.GetComponent<CUIDropdown>(); oUIDropdown.Init(oCanvas, oProp, aFieldsEnum); return oUIDropdown; }
public static CUIButton Create(CUIPanel oCanvas, CProp oProp) { GameObject oButtonResGO = Resources.Load("UI/CUIButton") as GameObject; GameObject oButtonGO = Instantiate(oButtonResGO) as GameObject; oButtonGO.transform.SetParent(oCanvas.transform, false); CUIButton oUIButton = oButtonGO.GetComponent<CUIButton>(); oUIButton.Init(oCanvas, oProp); return oUIButton; }
public override void Init(CUIPanel oCanvas, CProp oProp) { _oTextLabel = transform.GetChild(0).GetComponent<Text>(); // Label is always first child _oSlider = transform.GetChild(1).GetComponent<Slider>(); // Slider always second child _oTextValue = _oSlider.transform.GetChild(2).GetChild(0).GetChild(0).GetComponent<Text>(); // Value text at that relative address. ###WEAK _oSlider.minValue = oProp._nMin; _oSlider.maxValue = oProp._nMax; base.Init(oCanvas, oProp); }
public static CUIToggle Create(CUIPanel oCanvas, CProp oProp) { GameObject oToggleResGO = Resources.Load("UI/CUIToggle") as GameObject; GameObject oToggleGO = Instantiate(oToggleResGO) as GameObject; oToggleGO.transform.SetParent(oCanvas.transform, false); CUIToggle oUIToggle = oToggleGO.GetComponent<CUIToggle>(); oUIToggle.Init(oCanvas, oProp); return oUIToggle; }
public static CUISlider Create(CUIPanel oCanvas, CProp oProp) { //####IMPROVE: Can abstract some of this to base? GameObject oSliderResGO = Resources.Load("UI/CUISlider") as GameObject; //####IMPROVE: Cache GameObject oSliderGO = Instantiate(oSliderResGO) as GameObject; oSliderGO.transform.SetParent(oCanvas.transform, false); CUISlider oUISlider = oSliderGO.GetComponent<CUISlider>(); oUISlider.Init(oCanvas, oProp); return oUISlider; }
public virtual void Init(CUIPanel oCanvas, CProp oProp) { _oCanvas = oCanvas; _oProp = oProp; if (_oProp == null) Debug.Log("CUIWidget.Init has null property!!"); _oTextLabel.text = oProp._sLabel; SetValue(_oProp.PropGet()); _bInitialized = true; }
public void Init(CUIPanel oCanvas, CProp oProp, FieldInfo[] aFieldsEnum) { _oTextLabel = transform.GetChild(0).GetComponent<Text>(); // Label is always first child of prefab _oDropdown = transform.GetChild(1).GetComponent<Dropdown>(); // Dropdown is always 2nd child of prefab //_oDropdown.options.RemoveAll(); foreach (FieldInfo oFieldInfo in aFieldsEnum) { if (oFieldInfo.Name != "value__") { // Enums have a hidden 'value__' entry. Don't add it to drop box... Dropdown.OptionData oOptData = new Dropdown.OptionData(oFieldInfo.Name); _oDropdown.options.Add(oOptData); } } base.Init(oCanvas, oProp); _oDropdown.value = -1; //###LEARN: Original setting of drop down won't 'take' if we first don't set to other value than start value. base.Init(oCanvas, oProp); //###WEAK: We must init twice for above call to work }
public override void Init(CUIPanel oCanvas, CProp oProp) { _oButton = GetComponent<Button>(); // Button is our node _oTextLabel = transform.GetChild(0).GetComponent<Text>(); // Label is always 1st child of prefab base.Init(oCanvas, oProp); }
public override void Init(CUIPanel oCanvas, CProp oProp) { _oToggle = GetComponent<Toggle>(); // Toggle is our node _oTextLabel = transform.GetChild(1).GetComponent<Text>(); // Label is always 2nd child of prefab base.Init(oCanvas, oProp); }