当前位置:网站首页>Ilruntime learning - start from scratch
Ilruntime learning - start from scratch
2022-07-03 07:57:00 【qq_ two billion three hundred and eighty-five million seven hun】
1, ILRuntime The project is based on C# The platform of ( for example Unity) Provides a pure C# Realization , Fast , Convenient and reliable IL Runtime , Make it possible to support JIT Hardware environment ( Such as iOS) It can realize the hot update of code
2, Seamless access C# Off the shelf code of the project , No additional Abstract scripts are required API
The recommended way is to use directly ILRuntime Source code ,, such ILRuntime It can be optimized automatically according to your publishing settings .
3, Copy the following source directory Unity engineering Assets Catalog :
Mono.Cecil.20Mono.Cecil.PdbILRuntime
Delete these directories bin、obj、Properties subdirectories , as well as .csproj file .
ILRuntime Used unsafe Code to optimize execution efficiency , So you need to be in Unity In the open unsafe Pattern :
If you're using Unity5.4 And previous versions , And the compilation settings used are .Net 2.0 instead of .Net 2.0 Subset Words ,
You need to put smcs.rsp Change the file name to gmcs.rsp. If you're using Unity5.5 Version above , You need to put smcs.rsp Change the file name to mcs.rsp
Unity3D Example project of
You can https://github.com/Ourpalm/ILRuntimeU3D Download to the latest Unity Case Engineering , This example is in Unity5.5 Made under .
There are 2 A project , among ILRuntimeDemo yes Unity The main project . The examples are in each example scenario in this project , This project is in Unity5.5 Next is the finished
HotFix_Project It's hotter DLL engineering , use VS2015 And so on. C# IDE Open and compile , Please make sure to open it at least once before compiling Unity The main project , If the compiler still says it cannot be found UnityEngine etc. dll, Please manually re identify
from Visual Studio Start
stay VisualStudio Of C# Project use ILRuntime, You need to reference the compiled ILRuntime.dll,Mono.Cecil.20.dll as well as Mono.Cecil.Pdb.
Start using
Use ILRuntime It's simple , Only the following code is needed to run a complete example :
ILRuntime.Runtime.Enviorment.AppDomain appdomain;
void Start()
{
StartCoroutine(LoadILRuntime());
}
IEnumerator LoadILRuntime()
{
appdomain = new ILRuntime.Runtime.Enviorment.AppDomain();
#if UNITY_ANDROID
WWW www = new WWW(Application.streamingAssetsPath + "/Hotfix.dll");
#else
WWW www = new WWW("file:///" + Application.streamingAssetsPath + "/Hotfix.dll");
#endif
while (!www.isDone)
yield return null;
if (!string.IsNullOrEmpty(www.error))
D.error(www.error);
byte[] dll = www.bytes;
www.Dispose();
#if UNITY_ANDROID
www = new WWW(Application.streamingAssetsPath + "/Hotfix.pdb");
#else
www = new WWW("file:///" + Application.streamingAssetsPath + "/Hotfix.pdb");
#endif
while (!www.isDone)
yield return null;
if (!string.IsNullOrEmpty(www.error))
D.error(www.error);
byte[] pdb = www.bytes;
using (System.IO.MemoryStream fs = new MemoryStream(dll))
{
using (System.IO.MemoryStream p = new MemoryStream(pdb))
{
appdomain.LoadAssembly(fs, p, new Mono.Cecil.Pdb.PdbReaderProvider());
}
}
OnILRuntimeInitialized();
}
void OnILRuntimeInitialized()
{
appdomain.Invoke("Hotfix.Game", "Initialize", null, null);
}This example is for the convenience of demonstration , Directly from StreamingAssets The script is read from the directory DLL Files and debugging symbols PDB file , When actually released , If you want to be hotter , It must be DLL and PDB Package files to Assetbundle For dynamic loading ,
Debug plug-ins
Support Visual Studio2015 and Visual Studio 2017 Debugging plug-ins
https://github.com/Ourpalm/ILRuntime/releases
How to use it is as follows :
- install ILRuntime Debug plug-ins , And restart VS2015 or VS2017
- function Unity engineering , And ensure that appdomain.DebugService.StartDebugService(56000); To start the debug server
- use VisualStudio Turn on hot change DLL project
- Click... On the menu Debug->Attach to ILRuntime Button
- Fill the pop-up window with the name of the host being debugged IP Address and port of debugging server
- Click on Attach After button , It's like UnityVS Same as the breakpoint debugging
边栏推荐
- 华为交换机配置ssh登录远程管理交换机
- The general trend of data news releases the power of visual reporting ----- essays after reading
- VMware virtual machine configuration static IP
- 【cocos creator】获取资源uuid
- Go language foundation ----- 13 ----- file
- 华为S5700交换机初始化和配置SSH和TELNET远程登录方法
- Go language foundation ------ 14 ------ gotest
- Professor Zhang Yang of the University of Michigan is employed as a visiting professor of Shanghai Jiaotong University, China (picture)
- Go language foundation ------17 ----- channel creation, read-write, security shutdown, multiplexing select
- An article for you to understand - Manchester code
猜你喜欢

Pat grade a 1027 colors in Mars

Ventuz Foundation Series "one step at the door"

VMware virtual machine configuration static IP

Pat class a 1032 sharing

Go language foundation ------17 ----- channel creation, read-write, security shutdown, multiplexing select

Technical dry goods | thinking about the unification of dynamic and static diagrams of AI framework

*p++、*++p、++*p、(*p)++

STM32F103 SPI (pit Diary)

Redis批量启停脚本

【cocos creator】点击按钮切换界面
随机推荐
Uniapp learning records
My touch screen production "brief history" 1
Differences between tp3.2 and tp5.0
E: 无法定位软件包 ros-melodic-desktop-full
yarn link 是如何帮助开发者对 NPM 包进行 debug 的?
华为交换机:配置telnet和ssh、web访问
I want to do large screen data visualization application feature analysis
Huawei s5700 switch initialization and configuration SSH and telnet remote login methods
Clip Related Script
PHP common sorting algorithm
2020-12-12
What is definition? What is a statement? What is the difference between them?
Screenshot tool snipaste
Go language foundation ----- 16 ----- goroutine, GPM model
Project experience sharing: handwritten Chinese character recognition based on Shengsi mindspire
HDMI2.1与HDMI2.0的区别以及转换PD信号。
C2-关于VCF文件合并的几种方法
什么是数据类型?数据类型有什么用?
Enter three times and guess a number
C language learning notes (mind map)