사용한 프로그램
int[] arr = { 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7 };
arr.OrderBy(x=>Random.Range(0f,7f)).ToArray();
for (int i = 0; i < 16; i++)
{
GameObject go = Instantiate (card,this.transform);
float x = (i % 4) * 1.4f - 2.1f;
float y = (i / 4) * 1.4f - 3.0f;
go.transform.position = new Vector2(x,y);
go.GetComponent<Card>().Setting(arr[i])
int Idx;
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void Setting(int number)
{
Idx = number;
}
배열과 랜덤까지는 이해 했으나 이걸 따로 저장해서 랜덤값으로 표현하는 것을 보고 이러한 방법이 있구나 하고 새롭게 알게되었다.