The below code is a snippet of a test of what I'm trying to do. I know it isn't working as intended and I'm getting a "Destroying assets is not permitted to prevent data loss error". What I want to do is to have an array of instantiated GameObjects which I can then manipulate by accessing said array. Anyone have any tips on how I could accomplish this? Thanks in advance.
OLD array declaration.... `public GameObject[, ,] gemArray = new GameObject[6, 6, 6];`
NEW array declaration.... `public Object[, ,] gemArray = new GameObject[6, 6, 6];`
void Start () {
for (int i =0; i < 6; i++)
{
for (int j =0; j < 6; j++)
{
for (int k = 0; k < 6; k++)
{
if ((i != 2 && i != 3) || (j != 2 && j != 3) || (k != 2 && k != 3))
{
int num = Random.Range(1, 4);
switch (num)
{
case 1:
gemArray[i, j, k] = gem1;
Instantiate(gemArray[i, j, k, new Vector3(i, j, k), Quaternion.identity);
Destroy (gemArray[i,j,k].gameObject);
break;
Okay, after some experimentation on my end, I found that if i declare the array as an Object array instead of a GameObject array the operation
gemArray[i, j, k] = Instantiate(gem1, new Vector3(i, j, k), Quaternion.identity);
works correctly. However, I now cannot access any of the functions that I would have had access to(namely .tag and .transform). I'm not exactly sure of how to go from here...