using UnityEngine; public class Level_Generator : MonoBehaviour { public Vector2Int size; public Vector2 offset; public GameObject brickPrefab; public Gradient gradient; private void Awake() { for (int i = 0; i < size.x; i++) { for (int j =0; j < size.y; j++) { GameObject newBrick = Instantiate(brickPrefab, transform); Vector3 a = new Vector3((float)((size.x-1)*.5f -i) * offset.x , j * offset.y, 0); newBrick.transform.position = transform.position + a; newBrick.GetComponent().color = gradient.Evaluate((float)j /(size.y-1)) ; } } } // Start is called once before the first execution of Update after the MonoBehaviour is created void Start() { } // Update is called once per frame void Update() { } }