Hi guuys, i’m making a simple 2d game for android phones, however i’ve got one problem: on a galaxy s3 (a respectable quadcore) the game runs at 20fps.
The scene consists on a grid (9x9) and some picture and the draw calls are 4 (loving batching).
The main script has to do a cycle that repeats 9*9 times every update, could it be this that slows down the frame rate so much ? (In this cycle there are 10 lines where i always use GetComponent…).
Thank you in advance and sorry for the bad english.
Don’t use GetComponent in a loop.
yes, I know, but what else can i do ? the code is something like this:
foreach (…){
blabla.GetComponent().size =
blabla.GetComponent().color =
}
Save them in member variables. Create a new script for example, that contains BoxCollider and SpriteRenderer refences, then access them directly.