Instantiate prefab differences...

Let’s say I instantiate a prefab like this:

GameObject obj = Instantiate(Resources.Load("MyPrefab"), pos, rotation) as GameObject;

Is there a difference at all from if I had a public GameObject variable in my class, and then in the editor dragged a “MyPrefab” prefab to it, and then in code did:

public GameObject objToInstantiate; // set to "MyPrefab" object in editor

...
GameObject obj = Instantiate(objToInstantiate, pos, rotation) as GameObject;

Thanks!

In efficiency - how much time it takes to make the thing - there shouldn’t be too big a difference between the two methods.

The big downside with Resources.Load is that anything in the resources folder is included in your build. When you build your game, Unity grabs every object that’s referenced in a scene, and only those objects. This means that say a material that’s in your materials folder, but is never used, will not be included in your final game file (.exe or .app or whatever).

Stuff in the resources folder are the exception to this. As you can load those from script by giving the string path to the resource, Unity has no idea what parts of the Resources folder it should include or not, so it puts the entire folder in your build. So if you stop using an asset that you used to load from Resources, but forget to remove it from the folder, it will still be included in the final build.

The general advice is to avoid using Resources.Load. There’s also some comments on the same thing in the official docs, I’d suggest you take a look at what Unity says there.