Variable creation through Inspector using CustomEditor?

I'm working on a utility for an upcoming project, and I'm delving into the world of editor programming. I'm having trouble figuring out how to write a script that will allow the user to set a number of new vars and then name and fill in the values for them. I'm essentially trying to replicate the 'Animations' inspector field. Here's what I have so far:

@CustomEditor(SimpleExampleScript)
class CustomEditorExample extends Editor 
{

    function OnInspectorGUI() 
    {
        target.amountOfAnimations = EditorGUILayout.IntField("Total Animations ", target.amountOfAnimations);

        for(anims = 0; anims < target.amountOfAnimations; anims++)
        {
            var txt : String;
            txt = EditorGUILayout.TextField("Anim Name ", txt);
        }
    }
}

At the moment I can define the amount of animations and the text fields show up, but I'm lost on how to actually create new variables with these names for the user to fill in.

You can't add variables to existing, compiled classes. For such a task you would need to add source code to the actual script file and recompile it, but that's crazy. The animations property of the Animation-component is just an array. It's a bit tricky to extend an array because you need to recreate the array with the new size and you have to copy the old elements into the new array. If you use a container class like `List` that's much easier.

What exactly do you want to do? Doesn't an Array fit your needs? If you just need strings i would recommend to use a string array and the default inspector but if you have some special classes or handleing you can try to copy the Unity built-in array inspector but be warned: it has lots of optimisations that can be tricky to imitate.

You can even convert the array int a List (for your editor) and convert it back to an array.