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 ...
随机推荐
- 20.包含min函数的栈
题目描述: 定义栈的数据结构,请在该类型中实现一个能够得到栈中所含最小元素的min函数(时间复杂度应为O(1)). 思路分析: 设置两个栈,一个push,一个放置最小元素. 代码: impor ...
- PHP中SESSION无法获取问题
近期在看公司老项目,前台可以正常访问,但是后台却无法登录,一直报请求超时,请重新登录!进入服务后发现是有一处SESSION的值无法获取,这就让人很郁闷了,通常SESSION无法使用都是因为没有使用se ...
- Apache 在 htaccess 禁止访问 和 conf 中的 禁止访问 区别
相信熟悉Web Server的人一定熟悉Apahce.相信熟悉Apahce的人一定知道URL Rewrite.Apache的mod_rewrite模块,可以帮助人们构造出各种各样美化后的URL.在Ap ...
- P4159 [SCOI2009]迷路
传送门 先考虑只有 01 边权的情况 显然可以DP+矩阵加速 但是现在边权不止 1 然鹅最大也只有 9 所以从这里入手,把点拆成 9 个,然后点之间的边权也就可以变成 1 了 同样的转移和矩阵加速 注 ...
- laravel 用户名登录
laravel 用户名登录 默认登录设置为用户登录 laravel 5.3+ 修改文件(app\Http\Controllers\Auth\LoginController.php)增加 public ...
- pandas实例美国人口分析
- kafkaconsumer SimpleExample
package kafka.simple; import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Colle ...
- Log4web独立config配置
第一步:config配置,独立文件的 <?xml version="1.0" encoding="utf-8"?> <configuratio ...
- python模块之HTMLParser简介
html.parser是一个非常简单和实用的库,它的核心是HTMLParser类. 工作的流程是:当你feed给它一个类似HTML格式的字符串时,它会调用goahead方法向前迭代各个标签,并调用对应 ...
- 非局部均值(Nonlocal-Mean)
转载自网站:http://www.cnblogs.com/luo-peng/p/4785922.html 非局部均值去噪(NL-means) 非局部均值(NL-means)是近年来提出的一项新型的 ...