I have a number of GameObjects on the scene and I would like to Clone these and change name/tag and then add them to a List to be used later.
The problem i have is that when i change the name/tag it changes it on the prefab itself unless i instantiate it with another GameObject first. It will have “(Clone)” added to the name. I do not want to Instantiate until later.
So here is the code i am testing on:
for (int q = 0; q < flipContainer_List.Count; q = q + 6) {
// Load and add the new object
if (flipContainer_List [q].LastIndexOf ("B") == -1) { // Load front
string str_theTag = "";
str_theTag = flipContainer_List [q].Substring (1);
dummyGO = Resources.Load (str_theTag) as GameObject;
// dummyGO.name = "_" + flipContainer_List [q];
// dummyGO.tag = "_" + flipContainer_List [q];
float orgX = float.Parse (flipContainer_List [q + 1]);
float orgY = float.Parse (flipContainer_List [q + 2]);
float orgZ = float.Parse (flipContainer_List [q + 3]);
float orgTWIST = float.Parse (flipContainer_List [q + 4]);
int orgSortOrder = int.Parse (flipContainer_List [q + 5]);
dummyGO.transform.position = new Vector3 (orgX, orgY, orgZ);
dummyGO.transform.localEulerAngles = new Vector3 (0f, 0f, orgTWIST);
flip_GO_List.Add (dummyGO);
}
}
flipContainer_List contains of six properties where index = 0 is the name.
The new name & tag should have a “_” in front of the name, tags exists in the list.
How would i go about to add clones of existing GameObjects, change tag and name and then Instantiate it later?