Ok, so I’m really trying to learn something here, and I have gotten this rather complex system up running, where the game is loaded from all these differen logical bundles (sound in different languages, models in different versions etc.)
But I really have no deeper understanding on the subject. And when I read about bundles, it says you can’t have scripts in those, as they will be converted to text files. You need to do some external libs, and then use some reflection on those, Totally above what I know of…
Anyways. I DO have scripts. I have a core of logic, but the models themselves has their own specific game logic, which is loaded with the bundle. And it works fine. But I’m doing this on a regular pro license, just testing some concepts. Don’t own an iOS license, want to know first if it will be worth it.
What do I misunderstand? Why does it speak of scripts not being supported in bundles, yet it works fine so far?
I’m using scene bundles so far, is that it?
Ok, no replies, and I really need the info. When I build, and put the bundles in the data folder, I can load them fine from inside the game, and their internal logic (scripts and stuff) works fine. So what is up with the “Bundles don’t support scripts” in the docs? What is missing here? What do I misunderstand?
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 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.
The docs seems clear, no scripts will work as executeable code. But it works fine here. Is this because I’m building complete scenes, or what?
And IF this will indeed not work, how are you supposed to make additional content (with game logic) for iOS? Again, I’m just starting up trying to grasp the concepts, so excuse me, if this is very basic…
I think you’re misunderstanding the restriction - it’s specifically telling you that you can’t bundle standalone scripts as textassets and say, change them into a component and attach them to a gameobject, or run them separately. Correct me if I’m wrong, but the one caveat is that if you bundle up a component/script that doesn’t exist outside of the assetbundle, I think you need to make sure it’s referenced within the main project too so that the compiler knows to include it when it makes its build. That’s what it means when it says that you can’t use assetbundles to add functionality that doesn’t exist in the build.
So, if I have an external bundle, build from a complete scene, where scripts are already attahced to their respective gameobjects and such, there should be no problem? Because I can’t read the docs as what you just said there, but it makes sense, so it’s probably just me, not being very clever here.
Ok… I get it now. Sorry for all the stupidity. As I’m working in the same overall project, and my core code references the scripts used on the external objects (the once loaded in via bundles), these external scripts are obviously precompiled into the core project as well. That’s why it works. But if I make a completely new script, not referenced anywhere, and put that on my external object, build an asset bundle, and then delete the script from the project, it doesn’t work anymore. So…now I understand a lot more. Thanks.
Anyways. I need to be able to add new functionality with the asset bundles, as they will contain little minigames. And these minigames will be developed after the core has been released, so there’s no way my core functionality will have any chance of having a precompiled version of the minigame. It says it isn’t possible to use relfection on iOS, so how would one approach such a feature on iOS? Can anyone send me in some direction of knowledge? I can’t imagine noone has done this on iOS
(Just so you understand, I’m still just testing out some things, I’m not really developing a real product yet. But I need to know my limitations before even thinking about aquiring an iOS license)
EDIT: No, you know what, I have just found out how to obtain this knowledge myself, which is the best approach, always, so consider this thread closed for now…!
How did you apply it on iOS … and why does it seem like a secret to everyone … everyone is so vague about it … could you please tell me how did you provide scripts through asset bundles to the iOS?
This is always disappointing to see on any thread where the person solves their own problem. That doesn’t help anyone reading this, please share you knowledge with others
First of all, read the comment just before yours. It is one by me, telling it isn’t possible. Then read the comment you were quoting again, and realize that all I said was how I would research this myself, instead of trying to get a magic solution in here. After my research I found out: It isn’t possible.
Asset bundle will not contain scripts, but only reference to scripts, if there is a reference from any of the gameobject that is part of the asset bundle.
If you want to get the scripts may be you can create a unity package with scripts and import it.