How should I lookup for the value in the all of GameObject's class
I have multiple GameObject with class definying parameters. Right now I am implementing quests system and I need to detect if any of GameObjects has changed it's value, but I don't know how should I lookup through all of the GameObjects. The idea I came with is:
void Update()
{
if(questID.Any())
{
foreach (var quest in questID)
{
switch (quest)
{
case 1:
{
foreach(GameObject go in tiles)
{
TileManager tm = (TileManager)go.GetComponent(typeof(TileManager));
if (tm.tileLevel == 1)
{
Debug.Log("It works (trigger quest as completed)");
}
}
break;
}
}
}
}
but while it seems to be working - it's probably not the best in terms of optimization (two foreach loops within Update method, for 100 quests and 5000 game objects), I was thinking about delaying it with coroutine for 1-2s, as it's not really important to get the result of the quest in real time, but would it give anything?
Your answer
Follow this Question
Related Questions
struct and stepping? (quest line) 1 Answer
Removing Tris/Verts/Polygons from an merged mesh? (C#) 0 Answers
How to optimize this scripts ? 2 Answers
Mobile Optimization question 1 Answer