Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by thatCamelCode · Jul 23, 2016 at 02:23 PM · nullreferenceexceptionresources.loadtextasset

Why does Resources.Load keep returning null?

I'm pulling my hair out here... I've got a .txt file I'm using for loading in strings that my various objects will use to accommodate different languages. I first tried putting the text file in the StreamingAssets folder and accessing it that way, and that worked well until I tested it on Android (the target platform), where it wasn't accessing the file at all. So, I found the Resources.Load() method, and set up my project in that way.

I'm trying to read the file, but my problem is Resources.Load() is always returning null. I'm not including the extension, I'm type casting correctly (I've tried multiple ways of doing that just in case), and I've got my project files set up correctly as you can see here:alt text The file named English is a normal .txt file and Unity can open it, so I don't think there's an import issue.

The code I'm using is here:alt text currentLanguage is an enum and using the ToString method on it returns "English", which is the proper name of the file, without the extension, as the Unity docs specify. The resulting string in Resources.Load()'s path argument would then be "Languages/English", which is how I'm supposed to do it, right? I also tried putting the results of a Resources.LoadAll("") into the debug log and it turned up empty, even though the documentation for that method says that it should return all assets in the Resources folder.

I'm sure my mistake is a silly one, but for the life of me I can't find it and it's driving me crazy. I'm using Unity 5.3.5f1, by the way.

codescreenshot.png (12.4 kB)
filepathscreenshot.png (24.1 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by thatCamelCode · Jul 26, 2016 at 02:33 PM

Alright, I figured it out. When I put the English.txt file in the project, I did it through Windows Explorer instead of dropping the file into the Project view in Unity. Because of that, the text file wasn't properly converted to a TextAsset. It works now that I dropped the file into the project, instead of saving it directly in the project's assets.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

63 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to reference a filepath for streamreader on android device? 0 Answers

How is this Instantiate NullReferenceException? 0 Answers

Web Build Text Assets Aren't Working 1 Answer

Lose Object Reference when reloading a scene 0 Answers

Resources vs referanced prefabs 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges