Quantcast
Channel: Questions in topic: "clone"
Viewing all articles
Browse latest Browse all 508

how do i clone a button and then make it move and do it again?

$
0
0
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?

Viewing all articles
Browse latest Browse all 508

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>