In the first script top:
public List<GameObject> cloneList = new List<GameObject>();
Then in the Start function:
void Start()
{
Clone();
GetComponent<WayPoints>().cloneList = cloneList;
}
In the clone function i add objects to the cloneList.
Using a breakpoint i see tha the cloneList is filled with 10 objects.
Now i want to use this List in another script.
In the other script where i want to use the cloneList i did:
public List<GameObject> cloneList = new List<GameObject>();
public List<GameObject> waypoints;
Then in the Start function
void Start()
{
waypoints = this.cloneList;
}
But i’m getting null exception in the first script on the line:
GetComponent<WayPoints>().cloneList = cloneList;
The cloneList on the right after the = is not null. It’s on the left side something is null.
What i want is to fill the waypoints List in the other script with the cloneList.