My partner in game dev are looking at Unity. I dynamically loaded an asset using Resource.Load() and he used AssetDatabase.LoadAssetAtPath(). They both seem to work so which one should be used? Why have 2 different ways to dynamically load assets?
AssetDatabase.LoadAssetAtPath()
vsResource.Load()
...They both seem to work so which one should be used?
None of them.
Your partner will end up with a game that he cannot build because he used AssetDatabase.LoadAssetAtPath()
. The AssetDatabase.LoadAssetAtPath()
function came from the UnityEditor
namespace which is only used to make Editor plugins. It won't work outside the Editor and it won't even let you build your game at-all.
You using Resource.Load
is fine but Resource.Load
requires the use of the Resources folder which is known to cause slow down loading time of the game.
AssetBundles is the recommended way. You can put those files in the StreamingAssets folder then use the WWW
or AssetBundle
API to load it during run-time. You can learn more about how to use AssetBundles here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With