Hello. I’m currently trying to create a randomized array of GameObjects from an already established array, the problem being that I don’t want any of the elements to repeat themselves. Essentially, I just want to shuffle the original array contents randomly. I tried to use OrderBy but I got the error:
"UnityEngine.GameObject[ ]’ does not contain a definition for OrderBy' and no extension method
OrderBy’ "
This is my code up to this point:
using UnityEngine;
using System.Collections;
public class Comportamiento_principal : MonoBehaviour {
public GameObject[] listaPreguntas;
GameObject[] ordenPreguntas;
void Start () {
Random rnd = new Random();
int n=listaPreguntas.Length;
for (int i=0; i<n; i++){
ordenPreguntas[i]=listaPreguntas[rnd.Next(0,14)];
//ordenPreguntas = listaPreguntas.OrderBy(n=> rnd.Next()).ToArray();
}
}
void Update () {
}
}