Inspector arrays, dictionaries, etc.

I want to create some kind of damage matrix for damage resistance, susceptability, etc and need to input key, value elements based on an arbitrary set of data.

I see that Dictionaries, etc work for private variables, but don't appear in the inspector.

Is there anything I can use to display key, value elements in the inspector without having to create a variable for each?

I'm using c# as opposed to Javascript btw.

There's a few solutions to this. The nice way is to create a custom inspector for your script (see OnInspectorGUI), and create a custom gui for these settings.

The lazy way (I useually take this one :) ), is to expose something like a array of strings, and just fill them with "sworddamage=4" "magicdamage=12", and parse those strings on start. Not very elegant, but does the trick, and quite fast to program.

If I need to store a dictinoary, but don't need to manually edit it, I usually store two arrays, one with keys and one with values, and stitch them together on Awake()

You can also just make a custom class named for example Resistance, then fill it with variables like swordResistance, gunResistance and such, the custom class can then implement a function named GetDamage which will return a value of how much damage the unit will take from a specific damage type and damage value:

`public float GetDamage (DamageType type, float dmg) {

switch (type) {
   case DamageType.Gun
       dmg *= gunResistance;
       break;
 }

}`

Mark the class with System.Serializable and inherit it from System.Object to make it show up in the inspector.