I've made an editor which makes a list of tags and splits them into two rows of true or false values (selectable by the user). I then compile this list into a dictionary, and each entry is like so:

{"tag", bool, bool}

On my MonoBehavior script, I have two arrays:

string[] depth_tags;
string[] angle_tags;

My goal is to essentially save the dictionary data and be able to recall it/also have it affect the script. To do this, I've been trying to add to these arrays according to the values found in the Editor script's dictionary.

I've done quite a bit of searching and this was the only potential solution I could come up with, but sadly it did not work.

EDIT: Ok, I can now edit the list (added and subtracted from arraySize when doing operations on them), but I have a new problem:

The array reports as being twice as large as it should be. The first half of the arrays are correct and as they should be, but the latter half is made up of empty values. When I try to access beyond the first half, Unity throws an error saying that I exceeded the array's max range.


Answers telling you to increase and decrease arraySize are WRONG/OUTDATED. Clearing, inserting, and deleting from the table does that for you! Quick Tip: Inserting at index 0 in a serialized table takes care of the element bumping for you! No need to cycle through the table and move each array.

void update_tags()

    SerializedProperty depth_tags = serializedObject.FindProperty("depth_tags");
    SerializedProperty angle_tags = serializedObject.FindProperty("angle_tags");


    foreach (string tag in tag_list_values.Keys)

        if (tag_list_values[tag][0] == true)
            depth_tags.GetArrayElementAtIndex(0).stringValue = tag;

        if (tag_list_values[tag][1] == true)
            angle_tags.GetArrayElementAtIndex(0).stringValue = tag;





  • \$\begingroup\$ "but sadly it did not work" and what did it do instead? The precise symptoms of the problem can be a big help to identifying the right fix quickly. \$\endgroup\$
    – DMGregory
    Commented Mar 30, 2019 at 8:03
  • \$\begingroup\$ @DMGregory it did absolutely nothing to the MonoBehavior script. Tags were all fine and dandy in the Editor script, as well as their respective bool values, but it didn't change the depth or angle_tags lists at all. (It starts empty so maybe it was able to empty it, but my point is that it didn't ADD anything to it) \$\endgroup\$
    – Gmanicus
    Commented Mar 31, 2019 at 2:25

1 Answer 1


The property's array size needs to be edited every time (or appropriately before) an operation is made.

WRONG. Not sure what I changed to make it work, but I laid out my code in the original question.

  • \$\begingroup\$ Then please mark your question as answered. \$\endgroup\$
    – nihohit
    Commented Mar 31, 2019 at 3:34
  • 1
    \$\begingroup\$ @nihohit Have to wait a day to accept my own answer. \$\endgroup\$
    – Gmanicus
    Commented Mar 31, 2019 at 7:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .