Hello, I am making code to assemble a chess board.
Here is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class CreateBoard : MonoBehaviour
{
public GameObject TempTile;
public GameObject clone;
public Transform TileParent;
public List<int> positions = new List<int>() {0, 59, 118, 177, 236, 295, 354, 413};
public List<string> letters = new List<string>() {"a", "b", "c", "d", "e", "f", "g", "h"};
public string startingHash;
void Start() {
BuildTiles();
}
public void BuildTiles() {
for(int i = 0; i < 7; i++) {
Debug.Log(i.ToString());
for(int a = 0; a < 7; i++) {
Debug.Log(a.ToString());
clone = Instantiate(TempTile, new Vector3(positions[i], -positions[a], 0), new Quaternion(0, 0, 0, 0), TileParent);
clone.SetActive(true);
clone.name = letters[a] + i.ToString();
if(a%2 == 0 && 1%2 != 0){
clone.GetComponent<Image>().color = new Color32(0, 0, 0, 100);
}else{
clone.GetComponent<Image>().color = new Color32(255, 255, 255, 100);
}
}
}
}
}
Here is the output:
0
0
0
0
0
0
0
0
0
0