Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by XenonSpher · Jul 12, 2016 at 08:27 AM · assetbundleruntimebuild and runimport assets

how to import script at run time using AssetBundle?

I've read the documentation of AssetBundles, also the documentation about adding scripts in assetbundles. http://docs.unity3d.com/540/Documentation/Manual/AssetBundlesIntro.html http://docs.unity3d.com/540/Documentation/Manual/scriptsinassetbundles.html

the problem is I don't even know how to start.

"AssetBundles can contain scripts as TextAssets but as such they will not be actual executable code. If you want to include code in your AssetBundles that can be executed in your application it needs to be pre-compiled into an assembly and loaded using the Mono Reflection class (Note: Reflection is not available on platforms that use AOT compilation, such as iOS). You can create your assemblies in any normal C# IDE (e.g. Monodevelop, Visual Studio) or any text editor using the mono/.net compilers."

first of all how do we pre-compile into an assemby a script?

did anyone ever tried this? can anyone tell me how you'd manage to work this out?

Comment
Add comment · Show 2
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 XenonSpher · Jul 12, 2016 at 02:15 AM 0
Share

@AngryAnt please help

avatar image XenonSpher · Jul 13, 2016 at 04:09 AM 0
Share

to be exact I need a Runtime Standalone program that we can import a whole scene including its features and whatnot.

2 Replies

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

Answer by AngryAnt · Jul 12, 2016 at 12:41 PM

I'm somewhat disappointed that the Unity docs team decided to actually write up documentation on this hack, but not follow it through.

More information on this hack: http://angryant.com/2010/01/05/downloading-the-hydra/

At the bottom of the post you'll find an example bit of command-line for building an assembly out of your scripts. Note that you can do this more easily with something like Visual Studio or MonoDevelop.

The simple example in the post shows how to load the raw assembly as-is from a URL. Not an approach I would recommend. Aside from you probably wanting to keep the assembly in an asset bundle, you should definitely use some simple checksums to guard against man in the middle attacks.

Anywho, for the asset bundle approach, the trick is to save this .dll as a .bytes file in your Assets folder, which then gets imported as a TextAsset for you to store in an asset bundle and load at runtime.

You can find some example code of doing all of this in an automated fashion in my previous "Unity Hacks" talk: https://github.com/AngryAnt/UnityHacks/tree/master/Assets/Logic/Examples/Bundles

The video is available here: https://vimeopro.com/unity3djp/unite-japan-2013-english-sessions/video/64381935

If you want to go for the gold star and fully automate the process of building unique content, including logic, for loading into already distributed runtimes, I did a writeup on that here: http://angryant.com/2014/04/25/Construct/ - though fair warning this is likely overkill for most use cases and not for the faint of heart. I only undertook that expedition because it was required for a contract (they had approval over the post before I published it).

Even if my inputs on the topic are six (eep!), three, and two years old, it should all still work as-is. Though as the documentation page points out, the very nature of your goal means that it will never work on an AOT runtime and with the advance of IL2CPP, it is going to continue to lose relevance.

I hope that this is useful and helps you reach your goal.

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 XenonSpher · Jul 13, 2016 at 02:53 AM 0
Share

sad to say but your project is depreciated. and I can't do anything to it cause its advance as hell XD. I also saw your Japan session video and you really had good quick and snappy hacks and little tricks. your script bundle idea to save as bytes is great. but it won't let me work on your project so I'm gonna have to create my own. I'm gonna follow your idea and see if it works hopefully.. Thanks so much for the detailed answer sir!

avatar image AkshayGhosh XenonSpher · Mar 26, 2020 at 09:46 AM 0
Share

hi, @XenonSpher did you find a solution for importing the scripts at runtime .. any help is much appreciated.

avatar image
0

Answer by SpiralConDave · Feb 21, 2017 at 01:54 PM

I know this is scary, but could you do an Eval() ?

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

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Accessing AssetBundle at runtime on Android 0 Answers

How to load images/object at runtime and/or create assets server-side? 0 Answers

Create Assetbundles in final build? 0 Answers

How to import the object from server to unity 2 Answers

Level of Detail & AssetBundle streaming at runtime - possible? 0 Answers


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