How to instantiate a list of game objects multiple times?

I have a method which creates 2d sprites with specific width. After instantiate I add them to the list.
I want to have multiple instances of this list.
So I am planning to create two extra scripts. One to be responsible for positioning and order of these 2d sprites. (List basically serves as a group) and second for holding all variables.

How to instantiate sprite lists from another script using variables from the third?

I hope it make sense

Thank you very much

So you want to create in the scene, at runtime, several sprite prefabs, several times ?

If this is the case, you can use a foreach. If you don’t know how to use it : https://docs.microsoft.com/en-ie/dotnet/csharp/language-reference/keywords/foreach-in.


So you can create a bit of code wich, will instantiate every Sprite of your list (you can even set up some “filters” or selection criterias if needed ) and of course you can repeat this foreach with another foreach or with a for

Thank you. I have a script which creates road as a list from2d sprites.
I will also have pavement script which does almost the same.

I want to put all variable for crating these into separate script Specification and create another script which handles positioning of road and pavement.

This is road class

public class Road : MonoBehaviour
{
    [SerializeField]
    private StreetSpec newlaneWidth;

    //Road control variables
    public bool isRoadOnBothSides;
    public GameObject lanePrefab;
    public float laneWidth;
    public int numberOfLanes;
    private List<GameObject> laneList = new List<GameObject>(); 
    private float laneOffset;

   
    //Creates Road form lane objects.
    public List<GameObject> MakeRoad()
    {
        if (laneList.Count < numberOfLanes)
        {
            AddLane();

        }
        else if (laneList.Count > numberOfLanes)
        {
            RemoveLane();
        }

        ScaleLane(); //scales lane gameobjects in run time
        CheckLanePosition();  // checks and adjust lane position after scale change

        return laneList;

    }

    //Adds lane
    public void AddLane()
    {
        laneOffset = laneWidth * laneList.Count;
        GameObject lane = Instantiate(lanePrefab, new Vector3(laneOffset, 0, 0), Quaternion.identity);
        laneList.Add(lane);
    }

    //Scales lane
    public void ScaleLane()
    {
        for (int i = 0; i < laneList.Count; i++)
        {
            laneList*.transform.localScale = new Vector3(laneWidth, 1, 1);*

}
}

//Checks lane position
public void CheckLanePosition()
{
for (int i = 0; i < laneList.Count; i++)
{
laneList_.transform.position = new Vector3(laneWidth * i, 0, 0);_
}
}

//Removes lane
public void RemoveLane()
{
GameObject destroyLane = laneList[laneList.Count - 1];
laneList.Remove(destroyLane);
Destroy(destroyLane);
}

}
And this is generator class:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class StreetGenerator : MonoBehaviour
{

Road road; // reference to Road class

// Start is called before the first frame update
void Start()
{

road = FindObjectOfType(); // find Road class in the scene

}

// Update is called once per frame
void Update()
{
road.MakeRoad();
}
}
I saw a lot of tutorials about managers and player controllers. But they are very specific to games.
I am trying to have a set of classes which make staff, a class to hold all variables (so I can use ui to control it) and a class to instantiate all different game objects on the screen in a correct order, size an number using information from variable class.
A very small example will help me understand how to make it will be a great help
Thank you