当前位置:网站首页>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
边栏推荐
- Usage of (case, when) in PostgreSQL
- haproxy+keepalived搭建01
- Docker installs MySQL and successfully uses Navicat connection
- WorldView卫星遥感影像数据/米级分辨率遥感影像
- Technical dry goods Shengsi mindspire dynamic transformer with variable sequence length has been released!
- the installer has encountered an unexpected error installing this package
- 链式长取值
- 多旅行商问题——公式和求解过程概述
- Go language foundation ----- 13 ----- file
- Microsoft Security Response Center
猜你喜欢

Research shows that breast cancer cells are more likely to enter the blood when patients sleep

An article for you to understand - Manchester code

My touch screen production "brief history" 1

Redis批量启停脚本

多旅行商问题——公式和求解过程概述

【cocos creator】点击按钮切换界面

Open the influence list of "National Meteorological Short Videos (Kwai, Tiktok) in November" in an interactive way“

C language learning notes (mind map)

What is a data type? What is the use of data types?

Go language foundation ----- 10 ----- string related operations (operation function, string conversion)
随机推荐
超限黑客认知
Ventuz Foundation Series "one step at the door"
idea取消引用顯示效果
freetype库的移植
haproxy+keepalived搭建01
Introduction of novel RNA based cancer therapies
My touch screen production "brief history" 1
*p++、*++p、++*p、(*p)++
[MySQL 11] how to solve the case sensitive problem of MySQL 8.0.18
方正锐利重磅升级到12.0版本,包装印前处理更加便捷、高效!
一篇文章让你读懂-曼彻斯特编码
Getting started with minicom
Redis查看客户端连接
P1896 [SCOI2005] 互不侵犯(状压dp)
Uniapp learning records
[at] abc 258G - Triangle 三元組可達-暴力
Free use until 2015 -- viz artist multi touch plug-in package
Huawei switch console password reset, device initialization, default password
Go language foundation ----- 15 ----- reflection
华为交换机基础配置(telnet/ssh登录)