Exemplo n.º 1
0
    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));
    }
Exemplo n.º 2
0
    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);
    }