Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by simetra · Jun 22, 2020 at 11:27 AM · webglassetbundle

Problem with loading asset bundle in WebGL build

I built a scene into an asset bundle using the following piece of code:

 BuildPipeline.BuildAssetBundles(/*local bundle path*/, BuildAssetBundleOptions.ChunkBasedCompression, BuildTarget.WebGL);

Then I uploaded the extensionless asset bundle file (not the manifest file) to my google drive and got the download link. Now when I try to download and load the scene, it works in the editor but not in the WebGL build when I run it locally in Edge. Note that I also deleted all these files which appeared after the asset bundle building from my computer, and also cleared the scene, its dependecies (one texture) and meta files from the project folder to make sure the editor really gets the bundle from the drive. The code I use to download the bundle and load the scene in it is as the following:

 IEnumerator DownloadAndSetUpSceneBundle()
     {
         var uwr = UnityWebRequestAssetBundle.GetAssetBundle(@bundleURL);
         yield return uwr.SendWebRequest();
 
         AssetBundle assetBundle = DownloadHandlerAssetBundle.GetContent(uwr);
 
         string[] scenePaths = assetBundle.GetAllScenePaths();
         Debug.Log(scenePaths[0]);
         string sceneName = Path.GetFileNameWithoutExtension(scenePaths[0]);
 
         SceneManager.LoadSceneAsync(sceneName);
     }

It all works perfectly in the editor, but when I run the build locally using Edge, I get the following errors in the console:

SEC7120: [CORS] The origin 'file://' did not find 'file://' in the Access-Control-Allow-Origin response header for cross-origin resource at 'https://drive.google.com/u/0/uc?id=1iojUlUnleSAb_E4RFHTaooTC4iYiD7-n&export=download'.

Asset Bundle download is complete, but no data have been received

Please help me. Thanks in advance!

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

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by simetra · Jun 24, 2020 at 08:36 AM

As opposed to what Unity claims, this is NOT the best place for answers, not at all. It seems like people mostly dont care about questions of others, they just seek answers. Anyway, if you have the same problem as me, this is a cross-origin problem, meaning the WebGL game or web app is situated at domain-a.com while the asset bundle u are trying to download during runtime is located at domain-b.com which is not allowed by domain-b by default. You wanna have your bundle under the same domain as your web game/app, otherwise u have to permit the cross-origin access for domain-a in the source code of domain-b but I am not familiar with web development so go check that out yourself.

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
avatar image
0

Answer by Jon_Olive · Jun 25, 2020 at 09:13 AM

I've just had a very similar problem - though in my case the site the asset lives on is mine - so I was able to edit the .htaccess file to allow the cross origin resource sharing.

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
avatar image
0

Answer by williamfalvo · Jun 25, 2020 at 09:24 AM

Hi, you have to place the AssetBundles folder in the same place of the site.

For example if your WebGL site is into "http://www.example.it" url , so you can search and have to place your AssetBundles into "http://www.example.it/AssetBundle/ASSETNAME"

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

139 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 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 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

WebGL build crashes but game runs fine in editor and windows build. 0 Answers

How to prevent large font from increasing build size and load time of WebGL by 100% 0 Answers

Unity Cloud Build with Addressables for WebGL 0 Answers

UI image rendering on some devices but not others 0 Answers

Using CachedXMLHttpRequest 1 Answer


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