Possible To Add Variables Dynamicly?

Hello,

Is it possible to add public variables to a script according to another public variable dynamically?

Example:

var NumberOfVariables : int = 3; //input via inspector

var Variable1;
var Variable2;
var Variable3;

Example 2:

var NumberOfVariables : int = 5; //input via inspector

var Variable1;
var Variable2;
var Variable3;
var Variable4;
var Variable5;

So if the user changes the variable ‘NumberOfVariables’ in the inspector, it will then add a new variable according to the NumberOfVariables.

----- Why? -----

I have a enemy wave system that basically spawns a certain amount of enemy every wave. The user can choose how many waves to have, lets say 3 waves. With 3 waves inputted (inspector), 6 new variables are then added to the inspector (2 Variables for every wave), which are:

var WaveOne (amount of enemy in this wave)
var WaveOneHealth (health of enemy in this wave)

var WaveTwo
var WaveTwoHealth

var WaveThree
var WaveThreeHealth

These variables are all dependent on the amount of waves (which is just an ‘int’).

I hope thats clear,

Thanks

Use Builtin arrays. You could simply assign any number of variables you want in Inspector.(input the size of array)
Add below to your script:

var variables: int;