This seems like an unnecesary step. You don’t have to create a struct to pass as a parameter (Depending on the purpose). For this purpose in particular it seem unnecesary to do this as it would increase a memory footprint.
However there are instances where this would be required for readability (i.e. saving to a file or something). What you are doing here is creating a struct to initialize a class, this sounds pretty convoluted and
that’s so funny i forgot to use my laughing faculties. so pleease,… divide by zero. anyhow…
the question is:
in my weapon.cs i add field Enchantment - > that is a class.
Enchantemnt.cs has few fields like name,description and level.
i needed to serialize to xml all items. so i added [serializable] above the ench class name.
and had to remove : monobehaviour.
works. somehow. (i have my item as abstract so for now it seems to enchant all the same items.)(i guess its because of the abstract item)
but do you think it’s better to use class as a field or should i just add 3 fields,for ench name, desc and level?
I think its better to split the enchantment into a struct/class with the data of that enchantment,
this way the data is quite a bit better organized in your weapon itself. also if you want to get the enchantment of a weapon it is easier to grab the enchantment structure completely and take out what you need.
Doing the enchantment in a struct/class also allows you to add multiple enchantments to a single weapon, which is something you wont be able to do if you just add a few fields. therefore it really depends on the use case whether or not this is a good idea.