How do you create new variables so I can reuse the same variable name. For example I get an error saying newGrid and oldObj is already in use, I like to reuse them. Once Im done testing I might create a if loop for all my 27 grid sizes.
void EditGridColor() {
if (gridSize == 27) {
Transform newGrid = (Transform) Instantiate(gridRed, new Vector3(0, 0, 0), Quaternion.identity);
var oldObj = GameObject.Find("Main Camera/BuildMode/Grid/26");
newGrid.transform.parent = oldObj.transform.parent;
newGrid.transform.rotation = oldObj.transform.rotation;
newGrid.transform.position = oldObj.transform.position;
GameObject.Destroy(oldObj);
newGrid.transform.name = "26";
Transform newGrid = (Transform) Instantiate(gridPurple, new Vector3(0, 0, 0), Quaternion.identity); // newGrid variable is already defined error
var oldObj = GameObject.Find("Main Camera/BuildMode/Grid/25"); // oldObj variable is already defined error
newGrid.transform.parent = oldObj.transform.parent;
newGrid.transform.rotation = oldObj.transform.rotation;
newGrid.transform.position = oldObj.transform.position;
GameObject.Destroy(oldObj);
newGrid.transform.name = "25";
}
}