- Home /
Instantiating objects efficiently.
I am looking to have a racing game that has around 20 cars. I am currently keeping the built prefabs in the Resources folder. On game load they may potentially only use one of these 20 cars. To my understanding the Resources folder loads everything so essentially there are 19 other cars wasting resources that aren't getting used.
What is the best way to load a users car and have the other 19 possible to be loaded if need be? But if they aren't loaded they aren't wasting resources. Or is the Resources folder the right way to do it?
Thanks
Answer by haruna9x · Jan 25, 2019 at 07:50 AM
You may have misunderstood. Normally, Unity will look up the references of all assets within the project to decide whether to include it in the build. However, Resources is an exception, Unity knows nothing about Resources folder, so they will put everything you throw into this folder into your build. It's not about loading everything at the beginning of the game, it's your job, you need to manage the assets in the Resources folder yourself. Just move forward.
Good day @SamohtVII
As @haruna9x says, what is inside Resources folder, is stored in your build, but is not loaded. It does not reduce performance. ITs just files ready to be loaded. What it does i increase the size ($$anonymous$$B) of your build project.
Bye!
Your answer
