I’m trying to make myself a good practices guideline to work with unity. But I’m still a noob, So i’m searching for your help
I want to stop using the GameObject.Find, I’m trying to find all the ways posible for me to stop using it.
I think that a game object doesnt need to have a dependecy on another game object so in order to reduce this, I need to stop using gameObject.Find and reduce the number of gameobject references I expose in the inspector.
For this, I wanted to use a event driven methodology of communication between the GameObjects. ( this is my thinking, if someone has a better suggestion or critic regarding this please let me hear you. but this is not my question )
Ok, seems neat, but today reading about the resources folder I found this:
In Unity you usually don’t use path names to access assets, instead you expose a reference to an asset by declaring a member-variable, and then assign it in the inspector. When using this technique Unity can automatically calculate which assets are used when building a player. This radically minimizes the size of your players to the assets that you actually use in the built game. When you place assets in “Resources” folders this can not be done, thus all assets in the “Resources” folders will be included in a build.
So if I understand well, setting the assets in the inspector helps unity to achieve optimization by recognizing which assets are beign used and which not.
If I use GameObject.Find does unity still calculates which assets to build?
And if I recur to an event driven methodology, where a game object only listens and dispatches events that other Gameobjects will process, then will I loose this unity’s special ability to optimize the assets building?
I dont know if my question is kind of silly, maybe unity handles the assets different from the GameObjects, please correct me if is like this.