Quantcast
Channel: Answers for "Ordering a list of GameObjects"
Viewing all articles
Browse latest Browse all 6

Answer by BoredMormon

$
0
0
Essentially the error is telling you there is no natural way to sort a list of GameObjects. How do you tell if which GameObject comes first? You need to [provide a sort method][1] to GObj.Sort(). The following pseudo code sorts the GameObjects in alphabetical order by name. .... GObj.Sort(SortMethod(GameObject A, GameObjectB)); .... private int SortMethod (GameObject A, GameObjectB){ if (!A && !B) return 0; else if (!A) return -1; else if (!B) return 1; else return A.name.CompareTo(B.name); } [1]: http://msdn.microsoft.com/en-us/library/w56d4y5z(v=vs.110).aspx

Viewing all articles
Browse latest Browse all 6

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>