var fs = new FileStream(@"D:\Personal\My Documents\Projects\TestLib\TestLib\bin\Release\TestLib.dll", FileMode.Open); var b = new byte[fs.Length]; fs.Read(b, 0, b.Length); fs.Close(); var assembly = System.Reflection.Assembly.Load(b); var type = assembly.GetType("Test"); gameObject.AddComponent(type);
// Wait for download to complete yield return www;
// Load and retrieve the AssetBundle AssetBundle bundle = www.assetBundle; //TestDll 是资源的名字 TextAsset txt = bundle.Load("TestDll", typeof(TextAsset)) as TextAsset; print(txt.bytes.Length); // Load the assembly and get a type (class) from it var assembly = System.Reflection.Assembly.Load(txt.bytes); var type = assembly.GetType("TestDll");
// Instantiate a GameObject and add a component with the loaded class