Resources.Load() is the way to load ‘baked’ data (ie data that was shipped with Unity at compile-time). This is done via strings. Messy, messy strings. And what format are these strings?
pathis relative to any Resources folder inside the Assets folder of your project, extensions must be omitted.
This path value is surprisingly easy to get wrong! You can forget a folder, you can misspell the name, etc. So here is a simple script that you can use to copy the correct value to the clipboard with right-click or with cmd-alt-c. You can then paste this value into whatever you need, and not worry about it again! Enjoy.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|public static class CopyRefUtil|
|[MenuItem ("Assets/Copy Ref To Clipboard %&c")]|
|public static void GetReferencesString()|
|string path = AssetDatabase.GetAssetPath(Selection.activeObject);|
|if(path.IndexOf("Resources") > –1)|
|path = path.Substring(path.LastIndexOf("Resources/") + 10);|
|path = path.Substring(0, path.LastIndexOf("."));|
|EditorGUIUtility.systemCopyBuffer = path;|
|Debug.LogError("[Copy Ref To Clipboard] Not an object in a resources folder.");|