Assembly测试
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测试的更多相关文章
- 十一、springboot 配置log4j2以及打包成zip文件
前言 其实我们前面已经配置了日志,但是最近总感觉日志日志格式看的不舒服,并且每次打包都是一个jar 文件,lib都包含在jar 中,每次做很小的修改都需要重新替换jar文件,jar文件会比较大,传输起 ...
- 为C# as 类型转换及Assembly.LoadFrom埋坑!
背景: 不久前,我发布了一个调试工具:发布:.NET开发人员必备的可视化调试工具(你值的拥有) 效果是这样的: 之后,有小部分用户反映,工具用不了(没反应或有异常)~~~ 然后,建议小部分用户换个电脑 ...
- MAC上安装 HLA(High Level Assembly)
1.安装HLA 最新版的hla汇编器可在这里下载,支持MacOs,Linux,Windows平台 2.安装步骤 将下载好的hla程序包放在Mac根目录下 最重要的一步是设置好环境变量,打开Mac根目录 ...
- Linux+Mono+WebService:CS1703: An assembly with the same identity--mscorlib
最近把一些东西开始往Linux迁移了,因为老系统大部分都是.NET,所以直接使用Mono,代码一般都使用MonoDevelop把代码重新编译,把一些WMI和windows DLL调用改Linux的os ...
- 从零开始,搭建博客系统MVC5+EF6搭建框架(2),测试添加数据、集成Autofac依赖注入
一.测试仓储层.业务层是否能实现对数据库表的操作 1.创建IsysUserInfoRepository接口来继承IBaseRepository父接口 namespace Wchl.WMBlog.IRe ...
- [转]C#反射-Assembly.Load、LoadFrom与LoadFile进阶
关于.NET中的反射,常用的有三个方法: Assembly.Load()Assembly.LoadFrom()Assembly.LoadFile() 下面说说这三个方法的区别和一些细节问题 1. As ...
- [NHibernate]基本配置与测试
目录 写在前面 nhibernate文档 搭建项目 映射文件 持久化类 辅助类 数据库设计与连接配置 测试 总结 写在前面 一年前刚来这家公司,发现项目中使用的ORM是Nhibernate,这个之前确 ...
- 使用Microsoft Fakes隔离测试代码
在单元测试(Unit Test)中我们遇到的问题之一是:假如被测试组件(类或项目)为A,组件A依赖于组件B,那么在组件A的单元测试ATest中测试A时,也需要依赖于B,在B发生改动后,就可能影响到A的 ...
- 测试 ClownFish、CYQ、Entity Framework、Moon、MySoft、NHibernate、PDF、XCode数据访问组件性能
下期预告: 由于很多园友反馈,有的组件不应该缺席.测试复杂度不够.测试还缺乏一定的公平. 因此考虑在下一个版本中,确保在更加公平的前提下进行更高复杂度的测试 . 同时将分为2组测试,纯SQL组件及纯O ...
随机推荐
- 树状数组【bzoj1782】: [Usaco2010 Feb]slowdown 慢慢游
[bzoj1782]: [Usaco2010 Feb]slowdown 慢慢游 Description 每天Farmer John的N头奶牛(1 <= N <= 100000,编号1-N) ...
- CF580C Kefa and Park dfs
Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual pa ...
- Exadata扩展
所谓Exadata扩展,也即向现有的Exadata环境中增加新的数据库服务器或存储服务器. 扩展原则 可以依循以下规则扩展Exadata: (1).可以将Exadata从某种固定配置扩展到另一种固定配 ...
- main.obj:-1: error: LNK2001: 无法解析的外部符号 "public: virtual struct QMetaObject const * __thiscall CustomButton::metaObject(void)const " (?metaObject@CustomButton@@UBEPBUQMetaObject@@XZ)
QTCreator 运行时报错 main.obj:-1: error: LNK2001: 无法解析的外部符号 "public: virtual struct QMetaObject cons ...
- IE浏览器提示对象不支持“append”属性或方法
如下代码在IE浏览器中无法执行,提示对象不支持“append”属性或方法 var tImg = document.createElement("img"); tImg.setAtt ...
- day34 协程
1. 前提 之前我们学习了线程.进程的概念,了解了在操作系统中进程是资源分配的最小单位,线程是CPU调度的最小单位.按道理来说我们已经算是把cpu的利用率提高很多了.但是我们知道无论是创建多进程还 ...
- day22 正则表达式 re
1. 正则表达式 正则表达式是对字符串操作的一种逻辑公式. 我们一般使用正则表达式对字符串进行匹配和过滤. 工具: 各大文本编辑器⼀般都有正则匹配功能. 我们也可以去http://tool.china ...
- String转不同type的类对象
import org.springframework.beans.SimpleTypeConverter; private Object deserializeValue(Class<?> ...
- Unable to verify your data submission.加入了_csrf也报400错误的解决
<input type="hidden" name="_csrf" value="<?=Yii::$app->request-> ...
- free -m命令输出详解
free -m输出有3行: Mem:表示物理内存 -/+ buffers/cached:表示物理内存缓存 Swap:表示硬盘交换分区 其中Mem中的total.used.free.shared.buf ...