#Best format for storing a configuration

1 messages · Page 1 of 1 (latest)

ornate radish
#

I have a class called Effect that stores a collection of parameters that are unique to each Effect variant.

public enum EffectVariants { Slope, Noise, etc }

When I create a new instance, I have a factory that lets me return all the properites that Effect has

return effectType switch {
EffectVariants.Slope => new EffectData
{
  effectType = EffectVariants.Slope,
  parameters = new List<ParameterData>
  {
    new("Steepness", ParameterVariants.FloatField, new FloatValue { value = 1.0f })
  },
  {
    new("Reverse", ParameterVariants.Toggle, new BoolValue { value = false })
  },
},

The factory works, but it feels a bit cumbersome to work with, especially once I start populating it with many Effects. I'm debating whether I should possibly try doing it via json, or to replace the switch table with a dictionary. Perhaps theres an alternative way that could make this whole thing easier to do

#

The json I serialise the data into is like this, if thats a simpler way to see how my Effects data is structured

      "Effects": [
        {
          "EffectVariant": 1,
          "Parameters": [
            {
              "Name": "Size",
              "ParameterVariant": 0,
              "Value": {
                "value": 1.0
              }
            },
            {
              "Name": "Roughness",
              "ParameterVariant": 0,
              "Value": {
                "value": 0.1
              }
            }
          ]
        }
      ]
pine wedge
#

Configuring this in json is fine but why do you need to make new objects and a list to get the data? that seems wasteful unless this data can then bemodified

distant dew
#

I would use scriptable objects unless they are being modified at runtime. Then I would save to Json