I have empty gaemobject in the hierarchy.
Then in the script i create another empty gameobject and parent it as child to the empty gameobject in the hierarchy. The empty gameobject in the hierarchy is at position 374,0,0 and i set the child gameobject to 0,0,0
The script is attached to the empty gameobject in the hierarchy.
At the top of the script:
private GameObject emptygameobject;
In the Start:
private void Start()
{
emptygameobject = new GameObject();
int keys = 0;
foreach (var thisKv in List)
{
if (emptygameobject.name != result[keys])
{
emptygameobject.name = result[keys];
emptygameobject.transform.parent = transform;
emptygameobject.transform.localPosition = new Vector3(0, 0, 0);
Instantiate(emptygameobject, emptygameobject.transform.localPosition, Quaternion.identity);
}
keys++;
var key = thisKv.Key;
foreach (var thisValue in thisKv.Value)
{
GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
cube.transform.parent = emptygameobject.transform;
cube.transform.position = new Vector3(-thisValue.Y, 0, thisValue.X);
}
}
}
This is where i set the emptygameobject position to 0,0,0
emptygameobject.transform.localPosition = new Vector3(0, 0, 0);
This is a screenshot of the empty gameobject in the hierarchy I did in the menu: GameObject > Create Empty
The position of the gameobject is X = 374 Y = 0 Z = 0
The Hello World is on the right of the terrain. But i moved before running the game the gameobject to position 374 on the x.
Then i set the child empty gameobject in the script to 0,0,0
But still the Hello World is on the right of the terrain and not on the terrain.
The Hello World should be start from the terrain position 0,0,0 to 374,0,0