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
1
Question by Rascaile · May 21, 2015 at 10:47 AM · assetbundlecomponent

How to load an assetbundle with scripts in webGL

So I'm working on a project that uses Unity WebGL to display different machines/parts/.. in 3D, these parts or machines are selected by the user and then loaded into a scene (for now the scene stays the same).

Because of the large amount of choices we want to create different asset bundles, containing 1 or more parts each, so we can download these on-demand.

I've done this successfully by passing the URL to LoadFromCacheOrDownload and extracting the gameObject from the www object.

Now we would also like to include scripts with the assets to create animations and user interaction. I followed the explanation given here: http://docs.unity3d.com/Manual/scriptsinassetbundles.html, and this works perfectly in the WebPlayer. In webGL however, which is the requirement for our project, it gives the following error:

 NotSupportedException: /Users/builduser/buildslave/unity/build/Tools/il2cpp/il2cpp/libil2cpp/icalls/mscorlib/System/AppDomain.cpp(184) : Unsupported internal call for IL2CPP:AppDomain::LoadAssemblyRaw - "This icall is not supported by il2cpp."
 System.AppDomain.LoadAssemblyRaw (System.Byte[] rawAssembly, System.Byte[] rawSymbolStore, System.Security.Policy.Evidence securityEvidence, Boolean refonly)
 System.AppDomain.Load (System.Byte[] rawAssembly, System.Byte[] rawSymbolStore, System.Security.Policy.Evidence securityEvidence, Boolean refonly)
 System.AppDomain.Load (System.Byte[] rawAssembly, System.Byte[] rawSymbolStore, System.Security.Policy.Evidence securityEvidence)
 System.AppDomain.Load (System.Byte[] rawAssembly)
 System.Reflection.Assembly.Load (System.Byte[] rawAssembly)
 API+c__Iterator0.MoveNext ()

It seems to stem from the call "System.Reflection.Assembly.Load(txt.bytes);" (as seen in the example), so I suppose the Reflection class is not (yet?) fully supported for WebGL.

So my question is - is there a way around using Reflection for this? At best I'm hoping for some different code that can fix this, at worst that we will have to create the scripts for WebGL in Javascript and add them as such instead of as a binary? I'm a bit lost here so any leads are appreciated.

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

1 Reply

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

Answer by valyard · Jun 01, 2015 at 06:59 PM

As Josh Petersen answered on Stack Overflow:

No, there is no way around this restriction with reflection.

The key difference between the web player and WebGL build targets in Unity in this case is that WebGL uses AOT (ahead-of-time) compilation, whereas the web player uses JIT (just-in-time) compilation. With AOT compilation, it is not possible to load an assembly at run-time that was not present at compile time.

Of course, it is possible to load JavaScript code at runtime, so as you suggest, you'll probably need to go this route.

Comment
Add comment · Show 2 · 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 Rascaile · Jun 02, 2015 at 06:23 AM 0
Share

Thanks for the crosspost, this set me in the right direction, so I'll be poking around with scripts made in javascript and added as such.

avatar image Sujil-V-S Rascaile · Dec 30, 2016 at 06:22 AM 0
Share

Did you do loading a Javascript at run time from asset bundle and attaching that to a game object? If you already done that part for webgl, can you share me that code with me?

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How to import the object from server to unity 2 Answers

2D Animation does not start 1 Answer

Check whether a assetbundle has been already downloaded 3 Answers

how to save file from assetbundle to disk? 0 Answers

How to refresh Assets Folder in Unity Builds? 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