select gameobjects with screen rect in a large number of gameobjects
I want draw a rect on screen to select the gameobject; the issue is that there are 40000 gameobjects in scene; BoxCollider and Use OnCollisionStay is imprecise; MeshCollider is slow; Is there any way to solve the problem;
Answer by Laseph · Apr 14, 2017 at 10:06 AM
It's kinda inevitable to not run slow whilst selecting 40000 objects, i don't think there's an easy solution for this. You could just check for the position of an object and not its bounds but that's really inprecise. If you want to up the performance you could try doing it in a coroutine you're game won't slow down and depending on the amount of objects you do per frame, it will probably give good results. For example if you select 1000 objects per frame, it will only take 40 frames to complete. Indeed the amount of objects you select per frame will depend on the performance so you'll have to tweak it at first.
The best way to do it is with multi-threading, but I wouldn't use it if I were you. It could break your game.