Optimization: Inspector assigning

Hey!

I didn’t see any thema, for this.

If I have some staffs like GUISkin, Texture, another Game Object, etc., is it more effective, when I make it public in code and then assign in inspector, or when i found it with code? (let it be private and then find in Resources folder with code). I think, inspector should do the same work like me in code, is it true?

In this case, I’d say effective depends on usage. Objects referenced are also treated as dependencies, and dependencies sometimes are not what you want.

One clear example is atlases on mobile devices (SD & HD). If you reference both via inspector to a MonoBehaviour, they are both going to be loaded whenever that behaviour is loaded. You probably don’t want that, but load just one of them instead. So you could use Resources.Load to this in a more effective way.

Also, for handling references to child objects I’d prefer references from inspector. E.g. a script on your player holding a reference to his arm.

So:

  1. Referenced objects create dependencies. Resources.Load does not.
  2. Resources.Load need your objects to be placed on a Resources folder. Assets there are going to be included in your build. Even if you don’t use them.