Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class GameController : MonoBehaviour {
- public int width = 10;
- public int height = 10;
- private GameObject[,] grid;
- public GameObject block;
- public float blockSize;
- // Use this for initialization
- void Start () {
- grid = new GameObject[width, height];
- var gridWidth = width * blockSize;
- var gridHeight = height * blockSize;
- var beginX = -gridWidth / 2;
- var beginY = -gridHeight / 2;
- for (int i = 0; i < width; i++)
- {
- for (int j = 0; j < height; j++)
- {
- GameObject temp = (GameObject)Instantiate(block, new Vector3(beginX + i * blockSize, beginY + j * blockSize, 0), Quaternion.identity);
- temp.transform.localScale = new Vector3(1, 1, 1);
- grid[i, j] = temp;
- }
- }
- }
- // Update is called once per frame
- void Update () {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement