Load bundles with custom logic

Hello,
I need to create an application that loads a number of bundles.
Each of them is composed of the graphics (models, materials, textures) and logic (scripts) with references, within the bundle, to gameobject / materials / textures.

The problem is not loading the bundles at runtime, but load and properly handle the specific logic of a given bundle.

How can I make this application?

I’m considering the use of DLLs loaded at runtime, even if it seems it does not work on IOS, someone can help me?

Mmh, in some way I am interested too in this problem.

What is the best way to add new logic on a webplayer?
Add some scripts into an assetbundle or load dynamically dll files?

Any Unity3d Guru here? :slight_smile:

What I am searching for is a good way to load, at runtime, some new enemy type with some custom behaviour classes.
Using asset bundle I can load asset at runtime, but is I am not wrong I can’t load scripts.

Any idea?

Bump! :slight_smile:

You can’t load scripts at runtime. All the code should exist in the base application.

–Eric

Hello Eric,
thanks for your answer! :slight_smile:

Somewhere I read that is possible to load dll at runtime.
What about this?

Any script (even shaders) should be present inside the main application. There’s no way to load scripts via asset bundles. Scripts are not considered “assets”.

If you are loading assets bundles using some scripts/shaders, those should be already loaded by the main app or else you get errors.

Thanks Danko! :slight_smile:

Yes, I saw… it seems that Unity3d store in the bundles something link an id to refer to the script.

What do you think about loading dll at runtime?
Do you have any experience on this?

Any advise about runtime dll loading?

I guess this works in some systems (Window?). But I wouldn’t personally do it… how much code variation do you have so you should load it separately?

Shame that Unity cannot load and execute arbitrary code like Flash does (Flash can load another Flash and run it’s code). However, not having this possibility is better for security.

I am still in design phase and I don’t know exaclty how much variation …you totally right load and execute arbitrary code is a usefull feature that allow you to keep smaller the webplayer without useless code.

Just for information, why you don’t like dll import?

Unity3D allow Plugins… what do you think about that?
http://docs.unity3d.com/Documentation/Manual/Plugins.html

Just don’t want the UT to spend their valuable time on security issues (like Adobe did with Flash/Flex loading sub-modules). :slight_smile:

lol

… also I believe that WebPlayer isn’t the primary target for UT.

The main targets are still games (which are not supposed to load sub-logic from the web). Still nobody believes in Unity RIA. :wink:

…I don’t agree! :wink:

Please, look at this: http://blogs.unity3d.com/2012/12/03/unity-serious-games-highlight-reel-at-iitsec-2012/

Your GUI framework is very interesting… I am just waiting for the right project before to buy it.

Great, thanks! :wink:

I’m posting information in related threads of our community, to clarify how Shaders and Asset Bundles work together, and how to avoid some conflicts. The shader’s code is included with the asset bundle, whenever shaders are directly referenced as parameters in BuildPipeline.BuildAssetBundle(), or indirectly with option BuildAssetBundleOptions.CollectDependencies. This could cause a problem if you use BuildAssetBundle alone to create several asset bundles, since referenced shaders will be included in every generated bundle. There could be conflicts, i.e. when you mix different versions of a shader, so you will have to rebuild all your bundles for any modification. This also increases the size of bundles. To avoid these problems you can use BuildPipeline.PushAssetDependencies() to separate shaders in a single bundle, and that will allow you to update the shader bundle only. We are adding a page to the manual with more information on this topic and examples of the workflow to build a shader bundle.