|
i want to store my components in assemblies that i define and then put them in asset bundles. in this way, new functionality can be added to games. complete patches are easily possible. so can i create a car mesh and a car.dll assembly and make an asset bundle of them and then download it from my game and use it with it's new scripts? there is not any info about components in external assemblies nowhere. where should i put the dll? where should i put that for web players. where unity looks for external components. for example if i say
this is not real code. where unity looks for the component?
(comments are locked)
|
|
now it's possible to put components in dlls and use them. unity will recognize them in the editor. also i think from 3.2 we can add components from assemblies loaded in runtime as macfanpro answewred here. reflection is not needed anymore and you just need to use AddComponent with the type that is in the dll. Thanks for the update!
Apr 03 at 07:41 PM
Ray Pendergraph
(comments are locked)
|
|
I won't say you can't store it but I think the problem is that how do you get the unadulterated DLL bits out of the bundle? We tried this with other binary formats and the rather ugly workaround was to Zip compress then Base64 encode the bits as a text asset. Bad, bad, bad... but it was right before the release. It blew the game size up like a balloon. If you could figure out a way to say "Get this blob as raw bits" you could load the DLL internally and use it with some C# trickery. If you figure out how to do this with a DLL I would love to know... I'll update the community page. there is a good way to do that easily. you can use file reading http://system.IO of .net to read a encoded file (package of your pdfs) and then decode it and use it. for dlls, using reflection is possible but not as easy as i want.
Oct 14 at 04:11 PM
Ashkan
Sure you can read anything with http://System.IO but that gets tricky with a varying deployment base. What about web player, when will the content get installed to the drive?
Oct 14 at 04:18 PM
Ray Pendergraph
i just updated the answer with the up to date information.
Apr 03 at 01:19 PM
Ashkan
(comments are locked)
|
|
This is a quite complicated question, for a couple of reasons. First, Unity was not really intended for run-time modification of behaviors from external sources, and as such, you cannot really use, for instance, MonoBehavior from a outside DLL. However, there is a way around this, and that is to use your own behaviour class that exposes the same virtual functions as MonoBehavior and load those using C# reflection from a external DLL. What you could do is make a class like this:
Then extend it like this
You will need to put the external DLL containing ExtBehavior into Library/Frameworks, under the Unity folder. This is so the compiler can resolve the type of ExtBehavior. Then load the behaviors like this
Now, when you need a component, you just iterate through this array of Types until you find the one you need, construct it, cast it, then use it. I recommend creating a normal MonoBehavior that takes the name of the component that is loaded, as well as a Dictionary that takes parameters, then loads this dictionary into the external behavior through a protected constructor in ExtBehavior.
(comments are locked)
|
Unity Answers has moved to a new system, and some users may have trouble logging in.