First of all, thank you for reading this and excuse my ignorance (I haven’t used asset bundles other than testing them out)
So, I’m in the brainstorming phase of a new project (haven’t started it yet xD), long story short, a prison escape game, I’m thinking of adding functionality to download new maps (made by the developer or possibly a user who has a level editor)
I got to the conclusion that I need to use asset bundles, and download them through the client’s pc, but I got confuse because as far as I know, asset bundles can’t include scripts. Is there a way around it?
Are the asset bundles even suitable for the kind of functionality I need?
Can anyone point me in the right direction to how I can use them?
Asset bundles can’t include scripts, but if you have a script in your project and it’s tied to something in an asset bundle, it will still work. You just can’t add a new script that isn’t in your project.
I know one of my work projects is like this. The scripts are attached to game pieces and don’t require any inspector linking(no drag and drop references), but since the code is still in my project, the pieces work fine.
I suppose if done right, you could include a script and maybe a text file to help you set that script up for the player map creator portion.
If I release the game (I scripted it to find and use new asset bundles), I add a new functionality maybe, a laser gun (with a new script that isn’t in the client’s project), will the asset bundles still work or do I need to release all scripts that I would ever need with the client’s game?
Basically if you have a laser gun script in your project and you release an asset bundle with the laser gun model, texture, etc and the laser gun script is attached to it, it will work. Your game release has the laser gun script, even if it’s not used by anything else. A good way to think of it is all scripts are included in a build even if not used.
If you do the same thing, but you delete the laser gun script from your project, even though it is still attach to your asset bundle, and then try to load the asset bundle, it will give you a missing script error and isn’t going to work.
If you create a new laser gun with a new laser gun script and release that in an asset bundle, it isn’t going to work since your players don’t have the laser gun script.
Basically if you’re thinking of adding new scripts, you’ll have to have them update your game which will include your new scripts, then the asset bundles that use those new scripts will work.
Or, you try to build around it. Something like creating a generic weapon script that maybe pulls its info like damage, fire rate, clip size, etc from a text file.
Thank you very much!! Sorry for bothering you!!!
I don’t think I’m gonna be making this game (at least not in unity I guess), but I’m glad to know this stuff.
Not a bother. It was confusing for us as well when I was working on the project and we started using asset bundles. So a lot of this was just from testing out.
There may be other ways around this. Someone else might have other insight into ways to add new scripts through bundles, but there wasn’t anything that I saw when I started on them, but that was back during the during unity 5.1. Something new may have emerged since.
You could add a scripting environment such as Lua, which is a language many modders are comfortable with. This way you can expose specific C# methods to Lua that will give modders (and your DLC creators) the ability to mod the game without breaking it. There are a handful of free Lua implementations on the Asset Store.