I am using a Clipped Panel, which for now is anchored to UIRoot, as a container for my cubes in my Match 3 game I am working on. I am having issues constraining my cubes to be within the Panel. I want them to be sort of anchored to the Clipped Panel container so that they can resize along with the Panel when I deploy to mobile. I attached a script - GameManager.cs - to the Panel. I have also set the transform for the cubes to the parent transform. Below is the relevant code. How do I get the grid of cubes to be anchored to the Panel and size according to the UI?
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class GameManager : MonoBehaviour
{
public GameObject[] Cubes;
public GameObject panel;
void Start() {
}
void Update() {
for (int i = 0; i < Cubes.Length + 1; i++) {
for (int j = 0; j < Cubes.Length + 1; j++) {
int index = Random.Range(0, Cubes.Length);
GameObject myCube = Instantiate(Cubes[index], new Vector3(i, j, 0), Quaternion.identity) as GameObject;
myCube.transform.parent = panel.transform;
}
}
}
}
Thanks in advance