当前位置:网站首页>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.20
Mono.Cecil.Pdb
ILRuntime
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
边栏推荐
- 【踩坑系列】mysql 修改root密码失败
- Worldview satellite remote sensing image data / meter resolution remote sensing image
- C2-关于VCF文件合并的几种方法
- Idea unreference Display Effect
- Redis批量启停脚本
- [at] ABC 258g - triple Reach - violence
- C2 several methods of merging VCF files
- Huawei switches are configured with SSH login remote management switches
- What to do after the browser enters the URL
- Go language - loop statement
猜你喜欢
WPF:解决MaterialDesign:DialogHost 无法关闭问题
MAE
多旅行商问题——公式和求解过程概述
Iterm2设置
Zohocrm deluge function application time verification
Unity XR实现交互(抓取,移动旋转,传送,射击)-Pico
C language learning notes (mind map)
Go language foundation ----- 18 ----- collaboration security, mutex lock, read-write lock, anonymous lock, sync Once
【踩坑系列】mysql 修改root密码失败
Research shows that breast cancer cells are more likely to enter the blood when patients sleep
随机推荐
Structure of golang
the installer has encountered an unexpected error installing this package
oracle 插入单引号
STM32F103 SPI (pit Diary)
Client server model
P1896 [SCOI2005] 互不侵犯(状压dp)
LwIP learning socket (API)
Huawei s5700 switch initialization and configuration SSH and telnet remote login methods
idea取消引用显示效果
Are you still watching the weather forecast on TV?
Unity XR realizes interaction (grasping, moving, rotating, transmitting, shooting) -pico
JS common basic case sorting (continuous update)
[cocos creator] Click the button to switch the interface
Go language foundation ----- 10 ----- string related operations (operation function, string conversion)
Pycharm remote ssh pyenv error: pydev debugger: warning: trying to add breakpoint to file that does
Huawei switch basic configuration (telnet/ssh login)
创业团队如何落地敏捷测试,提升质量效能?丨声网开发者创业讲堂 Vol.03
PostGIS space function
Pat class a 1032 sharing
璞华PLM为全场景产品生命周期管理赋能,助力产品主线的企业数字化转型