How to store inspector values of script into array for later use?

I’m making a vehicle selection menu where you select your vehicle and said vehicle’s stats are stored in an array for later use.

So we have:

  • vehicle[0]
  • vehicle[1]
  • vehicle[2]

Each vehicle has this script attached to it:

public class Unit : MonoBehaviour {

	public Item item1;
	public Item item2;
	public float damage;
	public float speed;
	public Armor armor;
	public Health health;
	public Fuel fuel;
	public Range range;

A raycast script detects what vehicle we’re looking at in the selection menu:

	void Update () 
    {
        RaycastHit hit;

        if (Physics.Raycast(transform.position, transform.forward, out hit))
        {
            if (hit.collider.gameObject.name == "ChildPlatform0")
            {
                ApplyValues0();
            }
        }
        //scene view raycast visual
        Vector3 forward = transform.TransformDirection(Vector3.forward) * 10;
        Debug.DrawRay(transform.position, forward, Color.yellow);
	}
    //if Ready button is pressed, apply selected values to ?imaginary array?
    public void ApplyValues0()
    {
        if (readyButton.readyPressed)
        {
            Debug.Log("Values0 applied");
            childPScript.childP[0].GetComponent<Unit>();
            //I'm stuck here
        }
    }

How would I store all the values that were set in the inspector into a new array (I guess we can call the array “ReadyPlayers

Good day @abers1997 !

You should learn about Lists. They are like arrays but you can modify it adding/subtracting elements.

When a value is set, save it in this list.