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 ...
随机推荐
- 6.House Robber(简单版抢银行)
Level: Easy 题目描述: You are a professional robber planning to rob houses along a street. Each house ...
- 微信小程序生成带参二维码
需求:生成小程序中的海报,需要小程序二维码可以使用户保存到本地在朋友圈分享 生成二维码工具类代码如下: package com.aone.foottalk.action.wx.util; import ...
- 安装lombok
1. lombok的jar包路径 wangfei@DESKTOP-8AT8HRO MINGW64 /d/gradle-3.4.1/caches/modules-2/files-2.1/org.proj ...
- php 伪造HTTP_REFERER页面URL来源的三种方法
php获取当前页面的前一个页面URL地址,即当前页面是从哪个页面链接过来的,可以使用$_SERVER['HTTP_REFERER']; 但是$_SERVER['HTTP_REFERER']也是可以被伪 ...
- Linq 查询内建议不要使用运算语句!
比如list有2个值,当你运行完上述代码后,你会发现,你的ls中的Num没有按你预期的那样从0开始,导致这个问题的原因是:在你查询完毕后,执行的Count()方法,会导致查询语句中Num=num++再 ...
- 2018年 CCPC 网络赛 赛后总结
历程:由于只是网络赛,所以今天就三开了.一开始的看题我看了d题,zz和jsw从头尾看起来,发现c题似乎可做,和费马大定理有关,于是和zz一起马上找如何计算勾股数的方法,比较慢的A掉了,而jsw此时看了 ...
- HDU5950 Recursive sequence 非线性递推式 矩阵快速幂
题目传送门 题目描述:给出一个数列的第一项和第二项,计算第n项. 递推式是 f(n)=f(n-1)+2*f(n-2)+n^4. 由于n很大,所以肯定是矩阵快速幂的题目,但是矩阵快速幂只能解决线性的问题 ...
- setlocal 本地变量详解
命令 setlocal (开启本地变量) endlocal (结束本地变量) 很多新手不理解这句话是什么意思,在批处理中有什么作用. 其实在批处理中 setlocal 作用很大,配合 endloca ...
- python进制转换或数据格式转换
以下是部分进制转换的,都是python内置函数 int(x [,base ]) 将x转换为一个整数 long(x [,base ]) 将x转换为一个长整数 f ...
- Win10家庭版组策略gpedit.msc的问题
大家都认为,Windows家庭版中并不包含组策略,其实不然,它是有相关文件的,只是不让你使用而已.那么我们让系统允许你使用就好了.首先你需要在桌面上新建一个txt文本文档.然后将以下代码复制到这个新建 ...