I have a loop that instantiates a prefab multiple times, I want to add a script to each instance with code. Currently they are spawned with a for loop.
var gridx = Instantiate(Grid,transform.position + new Vector3( -220f+j*multi, 0.1f, -220+i*multi ), Quaternion.identity);
gridx.name = "Test Grid X " + i;
How can I add the component ?
I did try gridx.AddComponent but I got an error.
Type `UnityEngine.Object' does not contain a definition for `AddComponent' and no extension method `AddComponent' of type `UnityEngine.Object' could be found (are you missing a using directive or an assembly reference?)