Preface
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.
Code
FileName = "MapFiles/room_three";
TextAsset mapDataFile = Resources.Load(FileName) as TextAsset;
string text = mapDataFile.text;
Map thisLevel = new Map();
thisLevel = JsonConvert.DeserializeObject<Map>(text);
Problem
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 outResources.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 withResources.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.
Resources.Load
. – rutter Nov 4 '15 at 21:29