hello everyone,
I started to work with unity not long ago and I came across a problem. I used to load images with the Resources.Load and it worked fine, after a while I decided to add more files and more images. When added more images suddenly unity returns null. It is important to mention that the path reference is ok since I’ve been using the same folder as the images that do work. It drives me off the wall because when I try to test the code again and use the old images that I worked with, everything is fine I just can’t seem to make a reference to new created folders and images.
did anyone came across this problem before?
Are you trying to import a bundle? I don’t think resources works for bundles. You’d probably need to use Addressable Asset for that. I’m assuming you were trying to use the AssetBundleManager, which is depreciated in Unity 2018+ (I think).
Otherwise, your issue may be that you need to directly reference the objects:
Resources.Load("YourImageNameToThePath");
I don’t know that you can use Resources.Load<Sprite>(); unless you do it like this:
Resources.Load<Sprite>("PathNameHere");
Maybe if you show your code, but edit your path name for an example, I can be better help? Don’t post your actual file directory.
Thank you for responding, I am using the following code:
dialogueImage.sprite = Resources.Load<Sprite>("dialog_char/"+CharRight+"/"+RightCharEspression);
the ‘dialog_char’ file is located at ‘Assets/Prefab’, I printed the path and it is correct but still nothing is working with new files/images paths. I even tried to replace a working image with a new one (by simply changing the name of the new image to be the same as the old one that worked) and still get the old image. I hope I made the problem more clear.
lol, it turns out that I made sometime a copy of the dialog_char and I changed the images and the files in the copied folder, and not the original one that I was referencing to. anyway I got this thing worked out.
Perhaps this is the culprit in your other thread as well? The path is no longer valid because of copying the file?