Quantcast
Channel: Questions in topic: "crash"
Viewing all articles
Browse latest Browse all 2383

Nested Foreach Loop is freezing/crashing Unity.

$
0
0
Hi, I am attempting to create a list of classes. These classes have categories. Each class within the same category can have a "Rival" of that same category. I am using a nested foreach statement to find each class that is in my category and is not myself. The classes are rather large and have a lot of inheritence, so i don't know if Unity just can handle this much data, or i have some sort of error in my code that tunnel vision is blocking. The Function that is crashing private void SetRivals() { foreach (Network network in Networks) { List matches = new List(); foreach (Network target in Networks) { if(target.Category == network.Category) { if(target != network) { matches.Add(target); } } } network.SetPossibleRivals(matches); } } The Function being targetted public void SetPossibleRivals(List matches) { PossibleRivals.AddRange(matches); } If needed, i can post the whole Class. Thanks in advance!

Viewing all articles
Browse latest Browse all 2383

Trending Articles



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