Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class DrawChessBoard : MonoBehaviour
- {
- public GameObject square;
- void Start()
- {
- for (int x = 0; x < 8; x++)
- {
- for (int y = 0; y < 8; y++)
- {
- bool isLightSquare = (x + y) % 2 != 0;
- var squasreColor = isLightSquare ? Color.white : Color.black;
- Vector3 position = new Vector2(-3.5f + x, -3.5f + y);
- square.GetComponent<SpriteRenderer>().color = squasreColor;
- var obj = Instantiate(square, position, Quaternion.identity);
- obj.name = $"Position: {x}-{y}";
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement