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. kuangbin专题十六 KMP&&扩展KMP HDU3347 String Problem(最小最大表示法+kmp)

    Give you a string with length N, you can generate N strings by left shifts. For example let consider ...

  2. java经典学习路线

    恩,做开发的工作已经三年多了,说起来实在是惭愧,自己的知识树还像一棵小草一样,工作中使用到了许多的知识和技术,不过系统性不够.根基不牢.并且不够深入!当然,慢慢的我也更加的清楚,我需要学习一些什么样的 ...

  3. [USACO19FEB]Moorio Kart(DP)

    Luogu5243 题解 即O(N^2)暴力统计出每个森林的路径,从ctgn个集合中各选出一个数,使得长度>=Y的方案数. 用背包统计.具体实现: \(dp[i+j][0]\leftarrow ...

  4. Codeforces Round #482 (Div. 2) C 、 Kuro and Walking Route(dfs)979C

    题目链接:http://codeforces.com/contest/979/problem/C 大致题意 给出n个点,有n-1个边将他们链接.给出x,y,当某一路径中出现x....y时,此路不通.路 ...

  5. linux中firewall与iptables防火墙服务

    火墙firewall-cmd --state 查看火墙的状态firewall-cmd --get-active-zones 目前所处的域firewall-cmd --get-default-zone ...

  6. Spring boot的热部署

    当把配置文件,比如yml也打到jar包后,如何修改配置,而又不用重新发布呢? 在jar包同一目录下,放置Application.yml (注意,不管jar包内是否此文件名)修改配置文件后,重新启动ja ...

  7. Problem07 处理字符串

    题目:输入一行字符,分别统计出其中英文字母.空格.数字和其它字符的个数. 程序分析:利用while 语句,条件为输入的字符不为'\n'. import java.util.*; public clas ...

  8. 1.1 Rust安装

    从今天起,坚持每天学习10分钟Rust...这是一个刚兴起几年的语言,希望深入地进行学习,为什么呢,因为以下这些让人辛酸的理由..... 最开始学习的是C++,没学太懂,之后又学了C,这时还完全对计算 ...

  9. 几种经过整理的文件上传压缩和前台js压缩的方法

    /** * 图片压缩上传 * @param $im,图片资源 * @param int $maxwidth,最大宽度,超过这个宽度则进行压缩 * @param int $maxheight,最大高度, ...

  10. epoll 中ET与LT 关于读取处理 复习

    https://zhuanlan.zhihu.com/p/21374980 =============================================== https://zhuanl ...