[Unity实战]ILRuntime插件[新手安装教程](Unity2018及之后版本支持)

425 阅读1分钟

官方网址:

ourpalm.github.io/ILRuntime/p…
github.com/Ourpalm/ILR…

1.用Unity内置PackageManager搜索"ILRuntime"

1.1存在:

直接 “install”

1.2不存在

首先需要在项目的Packages/manifest.json中,添加ILRuntime的源信息,在这个文件的dependencies节点前增加以下代码

"scopedRegistries": [
  {
    "name": "ILRuntime",
    "url": "https://registry.npmjs.org",
    "scopes": [
      "com.ourpalm"
    ]
  }
],

如图:
在这里插入图片描述

然后通过Unity的Window->Package Manager菜单,打开Package Manager,将上部标签页选项选择为All Packages,Advanced里勾上Show Preview Packages,等待Unity加载完包信息,应该就能在左侧列表中找到ILRuntime,点击安装即可

1.3还是无法安装:

部分Unity版本可以无法直接在列表中刷出ILRuntime,如果左边列表找不着,那就在项目的manifest.json中的dependencies段的开头,增加如下代码手动将ILRuntime添加进项目
“com.ourpalm.ilruntime”: “1.6.0”,

如图:
在这里插入图片描述

1.4可以导入Demo

ILRuntime包安装完毕后,在Package Manager中选中ILRuntime, 右边详细页面中有Samples,点击右方的Import to project可以将ILRuntime的示例Demo直接导入当前工程。

1.5导入Demo报错

示例导入工程后有可能因为没开启unsafe导致编译报错,可以在PlayerSettings中勾选Allow unsafe code解决编译问题。

1.6打开热更DLL工程

在Assets\Samples\ILRuntime\1.6\Demo\HotFix_Project~目录中打开热更DLL的vs工程,直接编译,然后就可以正常运行ILRuntime的Demo示例了

1.7 最终解决方案

如果在进行以上配置后依然无法找到ILRuntime,可以按照下面Unity3D的示例工程的步骤手动安装ILRuntime

1.8 安装成功

在这里插入图片描述