Hey all,
I’m in the process of creating an objectRecycler with the base code provided by prime31 in one of his youtube tutorials. Linq is completely new to me, but I have some SQL knowledge so it’s not completely new territory I guess.
What I need to do is select a random GO in my List that also is also set to active == false. I’ve looked through the syntax from googling my question, but I can’t quite wrap my head around it. Here’s my query:
GameObject freeObject = ( from item in objectList
where item.active == false
select item ).FirstOrDefault;
Is there any short and simple way to select a random object that is qualified under my query as well? I’d really like to stick with Linq as it has some great functionality and I’d like to start incorporating it in lots of places, so please refrain from posting alternative methods ( ie standard array shuffling ). I also know that utilizing the extension method FirstOrDefault may not be appropriate for my selection, and I’m reading through the MSDN documentation but as I’m sure most of you know, Microsoft’s documentation is definitely not novice friendly. Thanks in advance.