using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class GridMaker : MonoBehaviour
{
public Button grid;
public int DistanceBetweenGridPieces; //how much distance between each grid piece
public int HowManyOnXAxis; //how many pieces across
public int HowManyOnYAxis; //how many pieces up
public Color StartingCorlor; //sets your starting color variable so you can change it in unity engine
void Start()
{
GetComponent().color = StartingCorlor; //sets the grid pieces to your starting corlor
float sizeY = GetComponent().rect.height;
float sizeX = GetComponent().rect.width;
float SizeInBetweenXOverAll = sizeX += DistanceBetweenGridPieces;
Debug.Log(sizeX);
Debug.Log(sizeY);
Debug.Log(SizeInBetweenXOverAll);
grid _btn = Instantiate(_btnPrefab, _theParent.transform);
grid.GetComponent () .anchoredPosition = new Vector3 (0, 0, SizeInBetweenXOverAll);
}
}
this is my code, the variable grid is the thing i am wanting to clone and then move and clone again and it continues like that. i made code that figures out the size of the grid and adds it to the distance between each grid you want that you would input in unity but how do i make it clone itself and then move?
↧