- Home /
Question by
ting · Mar 29, 2012 at 05:45 AM ·
runtimedllmonobehaviouraddcomponent
How to instantiate a MonoBehaviour from a downloaded DLL at runtime?
Hello,
Is it possible to download a DLL at runtime and instantiate a MonoBehaviour subclass in it? If yes, how?
The MonoBehaviour subclass is like this:
public class TestScript : MonoBehaviour {
...
}
I put the dll under Application.persistentDataPath, and tried:
GameObject go = new GameObject();
MonoBehaviour mb1 = go.AddComponent("TestScript") as MonoBehaviour;
MonoBehaviour mb2 = go.AddComponent(Application.persistentDataPath + "/TestScript") as MonoBehaviour;
but both mb1 and mb2 are failed with error:
Can't add component because class '...' doesn't exist!
I searched here and found:
http://answers.unity3d.com/questions/30143/how-can-i-put-components-in-external-dlls-and-stor.html
seems Unity3.5 does support to access component in a DLL, but how?
Thank you
Comment
Your answer
Follow this Question
Related Questions
Creating a component without a type dependency 1 Answer
Adding new code to built client 0 Answers
Attach C# Script on runtime 1 Answer