I made a script that makes an array of all the cubes in the current scene:
public GameObject[] allCubes;
void Awake()
{
allCubes = GameObject.FindGameObjectsWithTag("cube");
}
The problem is that the array looks like this in the inspector:
https://i.gyazo.com/69f2f844183fe6e592e61c1517267da1.png
I already try to do this:
public GameObject[] allCubes;
void Awake()
{
allCubes = GameObject.FindGameObjectsWithTag("cube");
Array.Sort (allCubes);
}
However, this gives me an error:
InvalidOperationException: No IComparable or IComparable<UnityEngine.GameObject> interface found.
System.Array.compare[GameObject] (UnityEngine.GameObject value1, UnityEngine.GameObject value2, IComparer`1 comparer) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/Array.cs:1756)
System.Array.qsort[GameObject,GameObject] (UnityEngine.GameObject[] keys, UnityEngine.GameObject[] items, Int32 low0, Int32 high0, IComparer`1 comparer) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/Array.cs:1722)
System.Array.Sort[GameObject,GameObject] (UnityEngine.GameObject[] keys, UnityEngine.GameObject[] items, Int32 index, Int32 length, IComparer`1 comparer) (at
What should I do?