I am working on a 2D Platformer in Unity5 utilizing TileMap techniques. I have a working system to read "Room Tile Data" from JSON files with the Unity TextAsset Class and the Newtonsoft JSON.Net library. My level files are within a folder inside of the Resources Directory and the Resources.Load is working on the json files with and without their .json file extension.

enter image description here


FileName = "MapFiles/room_three";       
TextAsset mapDataFile = Resources.Load(FileName) as TextAsset;
string text = mapDataFile.text;
Map thisLevel = new Map();
thisLevel = JsonConvert.DeserializeObject<Map>(text);


This works in the standalone builds for win + mac as well as in the Unity Editor. But a unity Web player Build entirely fails to load the TextAsset and my characters are left falling endlessly.


The only error I receive is a reference to mapDataFile.text being null. Leading me to believe my TextAsset is failing to load from the web player. The documentation says nothing I could find about using the TextAsset differently in the web player. Is there a different technique I must use to solve this issue for the Web Player? I'm certain I could change things to grab files on the web using WWW, but I want this data to be loaded from within the application.

Thanks in advance!

(edit) Updates:

  • Created a public property for the TextAsset and drag dropped the file into it. Still fails to load from the web player and worked in the standalones + editor. Assuming this means we can rule out Resources.Load as our culprit.
  • Tried the same functionality with Resources.LoadAssetAtPath which was only intended for use in the editor. When running this in the web player I received a similar verbose message. Nothing like this appears with Resources.Load
  • Updated "sample code" containing FilePath variable with file path string value being used in my application
  • Tested web player in FireFox / Chrome / Safari on Mac OSX 10.8 Yosemite
  • Pursued a potential cause found here: LINK TO ARTICLE I copied this technique implementing a scene 0 menu and the problem persisted with a weird flickering in Scene 0
  • Deleted Project "Library", "Temp" & "Project Settings" directories and let them be regenerated in conjunction with a few of these other attempts for good measure. Also removed / regenerated user preferences
  • Ran a "Reimport All" Assets by unity, Unsuccessful.
  • For posterity, I tried "Turning it Off and On Again" (Rebooting my Machine)
  • Uninstalled and Reinstalled newest Unity WebPlayer, unsuccessful.
  • \$\begingroup\$ FileName = "Folder/Within/Resources/level_one"; .... try FileName = "Resources/Folder/Within/level_one"; \$\endgroup\$ – War Mar 8 '15 at 18:17
  • \$\begingroup\$ then try without Resources bit \$\endgroup\$ – War Mar 8 '15 at 18:18
  • 1
    \$\begingroup\$ Are you building a streaming web player, specifically? And if so, have you set the "First Streamed Level" in player settings? Levels with an index below that setting will not have access to Resources.Load. \$\endgroup\$ – rutter Nov 4 '15 at 21:29

I tried to reproduce the situation, but it works regardless of what I do. Try to create a new playground project and repeat your situation, but stripped of irrelevant code and content.

P.S.: This should be a comment instead of an answer, but I don't have enough reputation here yet.

| improve this answer | |
  • \$\begingroup\$ giving this a shot now \$\endgroup\$ – Joe Mar 9 '15 at 2:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.