So i have been working on my script and i have set the position of an array to another gameobject, but when i run my game , it is set not till the end of my canvas corner ( i have looked every object and they are set to 0 or on the right position) . I decided that i must use whole array to set that position , because i have have tried to set the parent object to that position before it must be instantiated and it was set not to 0 of that gameobject position.
Here’s the script:
public GameObject[] cubes;
public GameObject Cloness;
.....
Camera mainCamera = GetComponent<Camera>();
Cloness.transform.localPosition = Camera.main.ViewportToWorldPoint(new Vector3(0, 0, 0));
for (int y = 0; y < gridY; y++)
{
Vector3 pos = new Vector3(Cloness.transform.position.x, y, 0) * spacing;
GameObject mySoundLine = Instantiate (prefab, pos, transform.rotation)as GameObject;
mySoundLine.transform.parent = Cloness.transform;
}
cubes = GameObject.FindGameObjectsWithTag("cubes");
Thank you for the help already ^^