On the 2.1 release notes it says that you can put a lot of content into streamable asset bundles (PRO ONLY)
On that same page it mentions meshes, textures,… but I don’t see the word SCRIPTS.
Suppose I have an enemy which consists of a skinned mesh, some textures/materials and of course the enemies AI as scripts atached all in 1 nice prefab ready to instantiate.
Can I then put my whole enemy including everything (also the prefab with scripting in place) into an assetbundle and in my game then load that from the www and instantiate the enemie with all scripting in place ?
I tried creating a new script in the AssetBundleAPI script that just printed “Boom 1” on Start to the console, then attached it to the ‘explosive guitex’ prefab, and exported that as an asset bundle.
It worked fine. But as soon as I deleted the BoomScript from my project, I got an error:
Just renaming the script will also get the same effect.
I recreated the script, but made it print “Boom 2” (and didn’t re-export the bundle). When I ran the program this time, it printed “Boom 2” not “Boom 1” as I had originally exported.
On the 2.1 release notes under Streaming Asset Bundles it says
It seems kinda tricky to create new missions and expansions without new logic. So there is probably some clever way of handling this, but I can’t see what it would be.
well the logic normally is part of the client itself , not of an expansion (media assets) so that would mean patching is the way to expand the logic …
Can not see any intelligent or even acceptable way to expand scripting that way as the compiler while building the app MUST know all existing functionality to decide if given code can work or not.
It can not just ignore it and “blind try at running”, thats .NET, not Ruby
oh…that’s not very great. So, if I have 20 costumers, each having a build of some project, and I want to add a new streamable game object (with completely new features and scripts), accessable by all costumers, I need to update all builds. That is kind of…damn…that is not good. Why is that? Is this going to change?
dreamora said: “Can not see any intelligent or even acceptable way to expand scripting that way as the compiler while building the app MUST know all existing functionality to decide if given code can work or not.”
Well, if I have tested that it will indeed work via my personal project, shouldn’t the compiler just accept that? I mean, the compilers error checking facilities are supposed to help me out here, not the opposite…
I hope this will change.
Asset bundles does not support what i would call true script assets. They merely make a reference to code exisiting in the client already, what this means is you can use any script that is on the client already in the asset bundles, but you cannot ship new code to the client by merely adding a script to an asset and making a bundle. The script will have to be on the client.
AFAIK there is nothing limiting you from downloading compiled .NET code and loading it yourself using the mono’s reflection and class loading system. So i don’t see any reason why this could not be implemented in the bundle system other than maybe time and some security issues.
Yes. Update all the builds to include the new scripts, but not for the other content.
You could make your own “download script asset” system using mono’s build in features for runtime loading of assemblies. There are quite abit of tutorials on the web on how to use C# to create runtime plugin system. These should in theory all work with Unity.
What is preventing you from just patching the client?
If you extract the assets to asset bundles this patching would be pretty small as the assets already exist.
If you drive that to the extreme, the client in the end could be “startup + scripts” only, making it a “framework” to execute the assetbundles on.
Marc: For the standalone, this approach would work, you are right.
But for the web player, this is definitely out of question for security reasons or do I miss something there? (or is the security part only applied at runtime not during build)
On a standalone you are still looking at a 4-5MB download for the framework depending on how many DLLs need to be included.
Another issue, since this streaming is aimed at MMOs, what would happen if you introduced a new enemy with new AI using this method? Any players who are currently connected would have problems. They would need to disconnect and update the client. I suppose this is why games like Eve Online turn the servers off every night.
Good question. I don’t have the answer as i only use standalone atm.
If i had to take a guess i would think that it depends on how Unity interacts with the browser cause somewhere they will have to load the mono classes that are included in the game, so it must be possible somewhere or nothing would run. Am i wrong on this?
I dunno if Unity disables this for security reasons?
Isent it possible to ship DLLs in a web build? think that will answer it.
Anyways is my guess, would test it as i would really love the feature, but don’t have the time atm.
What I want is to be able to load in dynamically some gameobjects, but these gameobjects should have scripts atached to them.
For example.
In my main unit app I have a room with a table. + 2 GUI buttons
1 button is labeled “blackjack”
the other button is labeled “memory”
Now when I press the blackjack button, I want to be able to load in somehow the needed gameobjects for a blackjack game + the scripts needed to run this blackjack game. They should all be loaded dynamically, because in my main unity app there will not be ANY of these gameobjects or scripts allready loaded.
Also, when I press the “memory”-button I want to have the blackjack assets to be unloaded and then load in te memory assets with atached scripts.
I know assetbundles can contain gameobjects and almost pretty everything, but can they also contain complete structures of gameobjects with their atached scripts ready in place ?