-
-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uncaught SyntaxError: Unexpected token '<' #57
Comments
Hey! No need for apologies, welcome! The error is thrown because your JSON file which is exported by Unity was not found. Your server probably returns a 404 page, which the module tries to parse as JSON. This fails at the first invalid character which is in this case The path you pass when creating the UnityContent object is relative to your HTML. This is because of the way the UnityLoader handles file loading. And besides that you would not want a big file chunk with Unity code inside if your bundle. this.unityContent = new UnityContent(
"MyUnityBuild/Build.json", // <------ This path *1
"MyUnityBuild/UnityLoader.js"
); So your file tree should look something like:
I hope this clears things up. Good luck! :) TL;DR Your json file path should be relative to your html file |
Perfect! It works! I was placing the build inside my src folder... Thank you for your help! |
I am having this same issue and I was wondering if anyone could assist me here. As far as i understand my file structure matches what is being asked but I am still getting the error. This is what I have. The build being in the same folder as the index.html should mean that this should work but I am still getting the error. Any assistance would be greatly appreciated. |
Are you able to view one of the JavaScript files from the browser? @RazrSlyr |
Do you mean through the sources tab in Inspect Element? If so, no. None of the JS files show up in the sources. |
No, I meant if you are able to view the file using the browser in a new tab. To confirm if the file is reachable as a public URL. |
Hello @jeffreylanters, I've had similar problems with @RazrSlyr, but right now it's still a blank screen 😢 I've set the dir to match what you have @RazrSlyr, but still no luck and this error of And I can't access the file from browser Much appreciate if you can help with this! |
I'm not sure if this is something with React itself or the package. I get this in the browser console when trying to load my Unity game
JSON.parse: unexpected character at line 1 column 1 of the JSON data
I've tested the same build outside of React and it loads without an issue.
Any help would be appreciated. My Unity version is 2018.3.1f1
The text was updated successfully, but these errors were encountered: