Hello!
This is what I’m looking for:
public List<GameObject> objects = new List<GameObject>();
//.......
void Check()
{
if(objects.Count() == 1)
{
GameObject obj = //THAT ONE OBJECT
}
}
How would you solve this? ![]()
Original post:
I have a list of selected GameObjects in my game, which I iterate through when assigning objectives etc. However, there are one objective that can only be done if only one object is selected. This is easily checked with the list.Count and so on. But if that returns “1”, meaning that only one object is selected - I want to assign the objective to it. However, I have previously used a foreach-loop to skim through the objects and assigning their objective… this is of course working even when the list only contains one object, but is there an easier way to access a particular object? From what I can see, I can get the index value of certain objects, but I don’t see a method where I can use that information to access the specific item.
The method will never run if the list.Count returns anything else than “1”. So I want to say, okay, then grab that item and tell it to do this…etc…
Thoughts? ![]()