public void OnFieldChange(BlockSettingsUI ui, object value, FieldInfo field) { var blockSpecs = blockCreator.BlockSpecs; if (blockSpecs == null) { return; } var convertedValue = Convert.ChangeType(value, field.FieldType); field.SetValue(blockSpecs, convertedValue); blockSpecs.OnValidate(); ui.SetValue(field.GetValue(blockSpecs)); }
private void CreateField(FieldInfo fieldInfo) { Type type = fieldInfo.FieldType; if (!menuCreatorDictionary.ContainsKey(type)) { return; } BlockSettingsUI ui = Instantiate(menuCreatorDictionary[type]); ui.transform.SetParent(transform); ui.SetFieldInfo(fieldInfo); ui.SetDefaultValue(fieldInfo.GetValue(blockCreator.BlockSpecs)); ui.AddOnSettingValueChangedListener(OnFieldChange); }