void ChangeType(int typeIndex) { string name = TypeDropdown.options[typeIndex].text; Type type = Assembly.GetExecutingAssembly().GetType("AffixValue" + name); if (type == null) { throw new InvalidOperationException("AffixValue type dropdown contained non-existant type!"); } previousType = TypeDropdown.value; UpdateValueDisplay(type); if (type != currentInfo.BaseValueMin.GetType()) { OnChangedStatusUpdated?.Invoke(true); input.OnChangedStatusUpdated -= UpdateLabel; UpdateLabel(true); } else { OnChangedStatusUpdated?.Invoke(false); input.SetValueInfo(currentInfo); UpdateLabel(false); } }
void UpdateValueDisplay(Type type) { if (type == typeof(AffixValueSingle) && !(input is AffixValueInfoSingleInput)) { Destroy(inputGO); inputGO = Instantiate(SingleValueInputPrefab, InputContainer); UpdateHeights(); } else if (type == typeof(AffixValueRange) && !(input is AffixValueInfoRangeInput)) { Destroy(inputGO); inputGO = Instantiate(RangeInputPrefab, InputContainer); UpdateHeights(); } else if (type == typeof(AffixValueMultiple) && !(input is AffixValueInfoMultipleInput)) { Destroy(inputGO); inputGO = Instantiate(MultipleInputPrefab, InputContainer); var input = inputGO.GetComponent <AffixValueInfoMultipleInput>(); input.OnHeightChanged += x => UpdateHeights(); UpdateHeights(); } var newInput = inputGO.GetComponent <AffixValueInfoInput>(); if (!ReferenceEquals(input, newInput)) { input = newInput; input.Initialize(); input.OnChangedStatusUpdated += UpdateLabel; input.OnChangedStatusUpdated += isChanged => OnChangedStatusUpdated?.Invoke(isChanged); } }