Extends opinion in inspector

Hi All!

I have a code to control animation like that:

public class EM : MonoBehaviour {

    public enum Type
    {
        Solo_Left, Solo_Right, Multiple
    }
    public Type type;
    public GameObject curveL, curveR;
    public int reps;
    public float speed;
    private Animator aniL, aniR;

    void Start () {
        aniL = curveL.GetComponent<Animator>();
        aniR = curveR.GetComponent<Animator>();
    }
    void Update () {
        if (type == Type.Solo_Left)
        {
            if (aniL.GetCurrentAnimatorStateInfo(0).IsName("Idle") && reps != 0)
            {
                aniL.speed = speed;
                aniL.Play("Take 001");
                reps--;
            }
        }
        if (type == Type.Solo_Right)
        {
            if (aniR.GetCurrentAnimatorStateInfo(0).IsName("Idle") && reps != 0)
            {
                aniR.speed = speed;
                aniR.Play("Take 001");
                reps--;
            }
        }
        if (type == Type.Multiple)
        {
            if (aniR.GetCurrentAnimatorStateInfo(0).IsName("Idle") && reps != 0)
            {
                aniL.speed = speed;
                aniR.speed = speed;
                aniL.Play("Take 001");
                aniR.Play("Take 001");
                reps--;
          
            }
        }
    }
}

3134202--237416--screenshot20170704182956.jpg
Which looks like that in inspector.

By using this code I can set up reps, speed , and choose the type of curveL and R in the inspector.
However currently it is a set of opinion. I want to make another public integer input so I can control the requiring sets of reps, speed, Type etc. For example, if the input integer is 2, it will have 2 sets of reps, speed, Type in inspector. if it is 5, it will allow me to have 5 sets. What should I do in order to reach that? Thanks for helping!

USE CODE TAGS:

Create a serailizable struct for the reps and speed:

[System.Serializable]
public struct Data
{
    public int Reps;
    public float Speed;
}

Declare an array of this struct in place of the original reps and speeds fields. And you’ll get a resizable array that you can fill with said data.

Already change the code tag, thank you!

So I tried your idea but it seems the array is only resizable inside c# rather than unity inspector. Could you please show me the code of the array?

public Data[] MyData;
// Or
public List<Data> MyDataList;

Make sure that the struct is just like the one @lordofduct provided (especially the [System.Serializable] part)

It doesn’t actually need to be a struct. Classes can be used in this fashion too. The key part is tagging it as serializable.