Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- public class Grid : MonoBehaviour {
- public GameObject[,] gridList = new GameObject[4,4];
- public int GridWidth;
- public int GridHeight;
- public GameObject gridPrefab;
- public GameObject SquarePrefab;
- void Start() {
- for(int y=0;y<GridHeight;y++) {
- for(int x=0;x<GridWidth;x++) {
- GameObject gridPiece = Instantiate(gridPrefab, new Vector3(x,y,0), Quaternion.identity) as GameObject;
- gridList[x,y] = gridPiece;
- gridPiece.transform.parent = this.gameObject.transform;
- GameObject SquarePiece1 = Instantiate(SquarePrefab, transform.TransformPoint(Vector3.zero), Quaternion.identity) as GameObject;
- SquarePiece1.transform.parent = gridPiece.transform;
- SquarePiece1.transform.localPosition = Vector3.zero;
- }
- }
- gameObject.transform.position = new Vector3(-1.5f, 0, 0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment