using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
public class TestAssembly : MonoBehaviour,System.IDisposable {
[System.Serializable]
public class BundleClass
{
public string name;
public AssetBundle bundle;
public BundleClass(){ }
public BundleClass(string _name, AssetBundle _bundle){
this.name = _name;
this.bundle = _bundle;
}
}
// Use this for initialization
private string AllDllBundlePath = "F:\\_Project\\Test\\test\\AllDllBundle.unity3d";
private string debugPath = "F:\\_Project\\Test\\test\\debuger.unity3d";
private string testFilesPath = "F:\\_Project\\Test\\test\\TestFiles.unity3d";
private string testdllPath = "F:\\_Project\\Test\\test\\debuger.unity3d";
// public TextAsset textAsset;
public List<BundleClass> bundleList;
void Start () {
if (null == bundleList) {
bundleList = new List<BundleClass>();
}
// Assembly assembly = Assembly.Load (textAsset.bytes);
// print (assembly.GetName());
StartCoroutine (GetDebuger());
StartCoroutine (GetTestFiles());
StartCoroutine(GetAllDllBundlePath());
}
IEnumerator GetAllDllBundlePath(){
WWW www = new WWW (string.Format("file://{0}",AllDllBundlePath));
yield return www;
if (null != www.error) {
print (www.error);
} else {
bundleList.Add (new BundleClass("AllDllBundle",www.assetBundle));
System.Type testFilesScript = GetTypeFromBundle (www.assetBundle,"TestFiles");
System.Type debugerScript = GetTypeFromBundle (www.assetBundle,"Debuger");
if (null != testFilesScript) {
print (testFilesScript.ToString());
this.gameObject.AddComponent (testFilesScript);
}
if(null != debugerScript){
print(debugerScript.ToString());
}
}
}
System.Type GetTypeFromBundle(AssetBundle bundle,string typeName){
TextAsset textAsset = bundle.LoadAsset(typeName,typeof(TextAsset)) as TextAsset;
Assembly assembly = Assembly.Load (textAsset.bytes);
print (textAsset.bytes.Length);
System.Type script = assembly.GetType (typeName);
return script;
}
IEnumerator GetDebuger(){
WWW www = new WWW (string.Format("file://{0}",debugPath));
yield return www;
if (null != www.error) {
print (www.error);
} else {
bundleList.Add (new BundleClass("Debuger",www.assetBundle));
System.Type script = GetTypeFromBundle (www.assetBundle,"Debuger");
if (null != script) {
print (script.ToString ());
}
}
}
IEnumerator GetTestFiles(){
WWW www = new WWW (string.Format("file://{0}",testFilesPath));
yield return www;
if (null != www.error) {
print (www.error);
} else {
bundleList.Add (new BundleClass("TestFiles",www.assetBundle));
System.Type script = GetTypeFromBundle (www.assetBundle,"TestFiles");
if (null != script) {
print (script.ToString());
this.gameObject.AddComponent (script);
}
}
}
void Update(){
if(Input.GetKeyDown(KeyCode.A)){
UnBundleAll (true);
}
if(Input.GetKeyDown(KeyCode.B)){
UnBundleAll (false);
}
}
[ContextMenu("UnBundleAll")]
void UnBundleAll(bool bTrue){
foreach (BundleClass bc in bundleList) {
print (bc.name);
bc.bundle.Unload (bTrue);
// bundleList.Remove (bc);
}
}
public void Dispose(){
print ("_______________Dispose");
}
}

  

Assembly测试的更多相关文章

  1. 十一、springboot 配置log4j2以及打包成zip文件

    前言 其实我们前面已经配置了日志,但是最近总感觉日志日志格式看的不舒服,并且每次打包都是一个jar 文件,lib都包含在jar 中,每次做很小的修改都需要重新替换jar文件,jar文件会比较大,传输起 ...

  2. 为C# as 类型转换及Assembly.LoadFrom埋坑!

    背景: 不久前,我发布了一个调试工具:发布:.NET开发人员必备的可视化调试工具(你值的拥有) 效果是这样的: 之后,有小部分用户反映,工具用不了(没反应或有异常)~~~ 然后,建议小部分用户换个电脑 ...

  3. MAC上安装 HLA(High Level Assembly)

    1.安装HLA 最新版的hla汇编器可在这里下载,支持MacOs,Linux,Windows平台 2.安装步骤 将下载好的hla程序包放在Mac根目录下 最重要的一步是设置好环境变量,打开Mac根目录 ...

  4. Linux+Mono+WebService:CS1703: An assembly with the same identity--mscorlib

    最近把一些东西开始往Linux迁移了,因为老系统大部分都是.NET,所以直接使用Mono,代码一般都使用MonoDevelop把代码重新编译,把一些WMI和windows DLL调用改Linux的os ...

  5. 从零开始,搭建博客系统MVC5+EF6搭建框架(2),测试添加数据、集成Autofac依赖注入

    一.测试仓储层.业务层是否能实现对数据库表的操作 1.创建IsysUserInfoRepository接口来继承IBaseRepository父接口 namespace Wchl.WMBlog.IRe ...

  6. [转]C#反射-Assembly.Load、LoadFrom与LoadFile进阶

    关于.NET中的反射,常用的有三个方法: Assembly.Load()Assembly.LoadFrom()Assembly.LoadFile() 下面说说这三个方法的区别和一些细节问题 1. As ...

  7. [NHibernate]基本配置与测试

    目录 写在前面 nhibernate文档 搭建项目 映射文件 持久化类 辅助类 数据库设计与连接配置 测试 总结 写在前面 一年前刚来这家公司,发现项目中使用的ORM是Nhibernate,这个之前确 ...

  8. 使用Microsoft Fakes隔离测试代码

    在单元测试(Unit Test)中我们遇到的问题之一是:假如被测试组件(类或项目)为A,组件A依赖于组件B,那么在组件A的单元测试ATest中测试A时,也需要依赖于B,在B发生改动后,就可能影响到A的 ...

  9. 测试 ClownFish、CYQ、Entity Framework、Moon、MySoft、NHibernate、PDF、XCode数据访问组件性能

    下期预告: 由于很多园友反馈,有的组件不应该缺席.测试复杂度不够.测试还缺乏一定的公平. 因此考虑在下一个版本中,确保在更加公平的前提下进行更高复杂度的测试 . 同时将分为2组测试,纯SQL组件及纯O ...

随机推荐

  1. 状压DP【洛谷P1896】 [SCOI2005]互不侵犯

    P1896 [SCOI2005]互不侵犯 题目描述 在N×N的棋盘里面放K个国王,使他们互不攻击,共有多少种摆放方案.国王能攻击到它上下左右,以及左上左下右上右下八个方向上附近的各一个格子,共8个格子 ...

  2. kuangbin专题十二 HDU1114 Piggy-Bank (完全背包)

    Piggy-Bank Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total ...

  3. Oracle 11G R2在用EXP 导出时,空表不能导出解决办法

    11G中有个新特性,当表无数据时,不分配segment,以节省空间 解决方法: 1.insert一行,再rollback就产生segment了. 该方法是在在空表中插入数据,再删除,则产生segmen ...

  4. windwos-sshfs

    从 http://www.jianshu.com/p/d79901794e3d 转载 目的 最近因为需要在linux虚拟机里进行开发程序,虽然在linux里有超强的编辑器vim,但vim开发html前 ...

  5. [Leetcode]015. 3Sum

    public class Solution { public List<List<Integer>> threeSum(int[] num) { Arrays.sort(num ...

  6. 增加tomcat多实例

    第一步:解压 第二步:修改端口 /data/service/tomcat1/conf <Server port="8006" shutdown="SHUTDOWN& ...

  7. c# yield关键字原理

    https://www.cnblogs.com/blueberryzzz/p/8678700.html c# yield关键字原理详解 1.yield实现的功能yield return:先看下面的代码 ...

  8. “随机数”函数的 ES6 实现

    生成一个指定长度的数字数组 const getNumArray = len => [...new Array(len).keys()]; const getNumArray = len => ...

  9. spring和springmvc父子容器关系

    一般来说,我们在整合spring和SpringMVC这两个框架中,web.xml会这样写到: <!-- 加载spring容器 --> <!-- 初始化加载application.xm ...

  10. python 16 进程和线程

    进程和线程 很多同学都听说过,现代操作系统比如Mac OS X,UNIX,Linux,Windows等,都是支持“多任务”的操作系统. 什么叫“多任务”呢?简单地说,就是操作系统可以同时运行多个任务. ...