you do not need the comma and Texture2D I don’t think. I think more likely, you aren’t storing your asset in a Resources folder. Make a folder called Resources and put it in there. It only works with that folder.
And um, please don’t put it in your Update loop or it will repeatedly try and load it forever, and probably freeze and die.
resources.load will not load from the assets folder only from Assets/Resources
This folder is completely present in the build and thats a core requirement to load from code (for any other folder this is not the case, the stuff there is only included when assigned to game objects in scenes)
Thank you. Now… that’s not clear in the documentation. In fact, it misleads us to believe that if we create some folders inside Resources we could use them to keep our stuff in a more organized way…
It’s not misleading. You can create subfolders under Resources. So, Assets/Resources/Player is perfectly valid, however if you want to target the stuff in there you have to do Resource.Load(“Player/filename”) should work(may need a slash before player also, but can’t recall that part off the top of my head). What you can’t do is create Assets/Player and then use Resource.Load to get the stuff out of that player folder.
Hello. I am new to Unity. I am trying to load a png file as a Sprite resource. I have read a hundred posts on Resources.Load failing and tried many things. Don’t know what is wrong. Here is my story.
I am testing this by pressing Play inside the Unity UI version ‘2018.1.1f1 personal’ I am running on OSX Sierra 10.13.5.
help1 is really help1.png stored in the Assets/Resources folder. When I moved it there Unity created a help1.png.meta file automatically.
35 Sprite s = Resources.Load(“help1”);
36 if (s != null)
37 Debug.Log("loaded help " + s.ToString());
38 else
39 Debug.Log(“resource load failed”);
when my code executes I get
resource load failed
UnityEngine.Debug:Log(Object)
HelpSwipeHandler:Start() (at Assets/Scripts/HelpSwipeHandler.cs:39)
The help1.png name is all lowercase. It is 1920x1080 in size, 72 pixels per inch, RGB color. It was created in Keynote and exported as a PNG image.
Any ideas? Any way to debug and get more info from what Resources.Load is doing?
Hello everyone.
I have the same problem with Resources.Load
1- I have the Resources folder.
2- the texture type of all assets in Resources folder is Sprite (2D and UI)
I found the solution.
Just changing the Resources.Load("LaunchButtonWith7ShotSlot_3Full") as Sprite to Resources.Load<Sprite>("LaunchButtonWith7ShotSlot_3Full") as Sprite