Hello! I have an external SDK with Code (CSharp): var settings = Resources.Load<SomeSettings>("SomeSettings"); if (settings == null) { throw new Exception("Can't find settings file."); } At some collab I started getting this exception. There are some changes in my project, SDK wasnt changed, SomeSettings file still exist and everything still works in the Editor. What could happen? What is the metodology of finding the solution in this case?
Resources.Load looks for something in a Resources folder, within the Assets folder. The first thing I'd check is that the something it is looking for is actually in a Resources folder.
Yes, resources foulder still contains the SomeSettings file. Also, I think there would be some errors in Editor if the file doesn't exist. And, as I mentioned before, there isn't any.
There are several things you should keep an eye out for. First of all any resources folder anywhere in your project will form a unified / merged virtual file system. So be careful with the naming of assets in resources folders because if you have a "SomeSettings" asset in /Assets/Resources/SomeSettings and another one over here: /Assets/SomeFolder/MySDK/Resources/SomeSettings, they will have the same name within the resources database. So make sure you have clear and unique names for your resources assets. Next thing is, just because there's an asset file with that name, does not necessarily mean it's the right asset. Keep in mind that ScriptableObject assets do have / need a reference to the actual class that it represents. Loosing the meta file of the scriptable object could cause a break in this reference. So there are a lot things that could have gone wrong due to some careless handling of the files. Can you post the script file of that settings file and maybe the content of the asset file (which should be yaml text)? Also the content of the meta file of the scriptable object class may also be useful. Though it's difficult to do a diagnosis of such issues through forum communication. Another thing you can check is if you have more than one of those "SomeSettings" classes, maybe in different namespaces? Serialized classes can cause issues if they have evil twins somewhere.