Hi, so I want to instantiate array of game objects via editor scripting. Now the problem is when I instantiate the prefab it lost it’s parent in hierarchy. When I’m instantiating like the script below it works just fine :
for(int i = 0; i < 20; i++){ //_dTarget.halfLength; i++){
GameObject a = (GameObject)PrefabUtility.InstantiatePrefab(_dTarget.wallTile);
a.transform.parent = goTarget.transform;
}
but if I instantiating like this :
GameObject[] testG = new GameObject[20];
for(int i = 0; i < 20; i++){
testG[i] = _dTarget.wallTile;
}
for(int i = 0; i < 20; i++){ //_dTarget.halfLength; i++){
GameObject a = (GameObject)PrefabUtility.InstantiatePrefab(testG[i]);
a.transform.parent = goTarget.transform;
}
they lost their parent and instantiated outside the parent : Upload and share screenshots and images - print screen online | Snipboard.io
Any ideas why this happens ?