|
So I have a DLL with a class ResourceManager implemented as a singleton. The GetInstance() method for the class has the following code..
where cInstance is defined as..
This is all happening inside a DLL which is placed in the Plugins folder of my Unity project. So when I make the following inside a script in my Unity scene,
I get the following error..
So, is it the case that, this kind of code just will not work because it is in a dll or is there something wrong in the way I have done things here? NOTE: as of Unity 3.x this is now possible.
(comments are locked)
|
|
unity does not support components in external assemblies. a class library (DLL) is an external assembly and you can not have a component in it. I am a bit confused.. I guess MonoBehaviours are components, and we are allowed to have MonoBehaviours in DLLs.. Is it just that we can't add or get components using the usual methods in these DLLs?
Jan 13 '10 at 09:38 PM
lokstok
you can not add a component that is in an external assembly. see the comments of a post called "donwloading hydra"in angry ant's website http://www.angryant.com the post is not about external assemblies and components. it's about downloading code and executing it but in comments you can find what you want.
Jan 14 '10 at 02:10 PM
Ashkan_gc
UPDATE (for those who stumble upon this question) http://answers.unity3d.com/questions/30143/how-can-i-put-components-in-external-dlls-and-stor.html
May 27 '11 at 07:53 AM
Quazistax
(comments are locked)
|
|
As the error says, components need to derive from the Component class. For scripts inside unity, that means you have to define your class like this:
or, as is more commonly used (and is the default when unity creates a new c# script):
This works because MonoBehaviour derives from Behaviour, which itself derives from Component. Whether or not you can do this in your DLL, I'm not sure. I'm guessing you would have to add the UnityEngine.dll to your project, if it's not added already. I have derived from my ResourceManager class from MonoBehaviour. The class is defined as public class ResourceManager : MonoBehaviour Also the dll project does include the UnityEngine.dll else it wouldn't have compiled..
Jan 13 '10 at 06:22 PM
lokstok
ok - just had to check! In that case I have no idea.
Jan 13 '10 at 08:40 PM
duck ♦♦
(comments are locked)
|
|
(comments are locked)
|
