How can I Instantiate a GameObject and then alter an array that is attached to that GameObject

I can currently Instantiate the GameObject just fine, but I have a script attached to it that has an array for waypoints that I would like the object to move back and forth to. In the editor I was able to manually set waypoints by dragging empty gameobjects into the array, but I would prefer to instantiate these empty objects and set their transform.position via this BuildLevel script instead. This is the part I am stuck on. The goal is to be able to have multiple enemies each with their own waypoints to patrol.

Here is the code I am using to instantiate my GameObject(some code is snipped):

public GameObject Enemy2Way;

public void BuildLevel(int whatLevel)
	{
		if (whatLevel == 0) 
		{
                    Instantiate (Enemy2Way, new Vector3 (0, 1, 5), Quaternion.identity);
		}
	}

And here is the script that is attached to the Enemy2Way gameobject:

	public Transform[] patrolPoints;
	private int currentPoint;
	public float moveSpeed;
	
	void Start () {
		transform.position = patrolPoints [0].position;
		currentPoint = 0;
	}
	void Update () {
		if (transform.position == patrolPoints [currentPoint].position) 
		{
			currentPoint++;
		}
		if (currentPoint >= patrolPoints.Length) 
		{
			currentPoint = 0;
		}
		transform.position = Vector3.MoveTowards (transform.position, patrolPoints [currentPoint].position, moveSpeed * Time.deltaTime);
	}
}

Change:

Instantiate (Enemy2Way, new Vector3 (0, 1, 5), Quaternion.identity);

To:

GameObject Temp = Instantiate (Enemy2Way, new Vector3 (0, 1, 5), Quaternion.identity) as GameObject;
Temp.GetComponent<WhateverTheNameOfYourSecondScriptIs>().patrolPoints = new Transform[...];

Replacing … with your desired array of transforms.

It might be better to create a method in the EnemyControl script that initialises the array. Using this approach you ensure that the array is handled the way that the EnemyControl script expects. You can do this by making the array private and adding a public initialization method. Then you would just use:

GameObject go = Instantiate(Enemy2Way, new Vector3(0,1,5), Quaternion.identity);

(EnemyControl)go.GetComponent(typeof(EnemyControl)).InitializeWaypoints(4); //4 is the number of waypoints to be initialized

Use of c# generic list might also be easier.