当前位置: 首页 > news >正文

HotReload for unity支持的代码修改

HotReload for unity支持的代码修改

HotReload的版本:1.2.4
Unity版本:2020,2021,2023
创作日期:2023.10.25

总结一下

  1. 支持在运行的时候修改异步,同步,重命名方法,修改方法参数,返回值,out,ref,访问修饰符,更改任何方法的返回类型,包括实例方法、静态方法、属性、事件、索引器、泛型方法等。
  2. 支持修改字段的任何信息。
  3. 可以修改部分携程中的方法,可以修改Invoke中的方法,可以修改InvokeRepeating 中的方法
  4. 不支持在运行的时候新建变量
  5. 不支持在运行的时候创建新的Class 新的结构
  6. 不支持添加/编辑枚举
  7. 不支持
    添加、编辑、删除字段
    添加新类/结构
    添加、编辑、删除结构的构造函数
    添加/编辑枚举
    编辑泛型类方法
    在部分类型中编辑变量初始化程序
    编辑具有动态返回类型或其中一个参数使用动态的方法体
    添加或删除以下方法关键字之一:partial、abstract、virtual、override、extern
    删除类的构造函数不会删除构造函数的逻辑。作为一种解决方法,考虑保留一个空构造函数而不是删除它,可能在下次进行完全重新编译时删除构造函数。
    已执行的异步方法不会进行修补 - 仅新的调用将使用更新后的逻辑
    支持动态生成的代码,例如Unity Multiplayer hl-api、Photon、Bolt、Mirror等库生成的代码
    添加C#文件
    将更改应用于正在进行的协程。

支持的语法Supported Features

  • Editing functions in monobehaviours, normal classes or static classes
    You can edit the body of the function in any way that is valid C#. We recompile the whole function, so it works the same as you’re already used to.(可以直接修改MonoBehaviours、普通类或静态类中编辑函数中的函数)

  • Editing lambda methods
    If you modify a lambda, we hot-reload the existing lambda. So for example, store a lambda in a static field during startup, and then edit the lambda without running startup code, your change to the lambda will still apply immediately.(可以编辑Lambda 方法)

  • Editing lambda methods with closures
    If you use an outside variable inside your lambda, your lambda will work as usual. If you use a new outside variable, then your lambda will be hot-reloaded only when you create it again. for example the lambda in Array.Sort(() => …) is recreated every time you run the code, so it will always work as expected.(支持闭包的 Lambda 方法的编辑)

  • Editing async/await methods(支持:编辑异步/等待方法)

  • Editing properties (get/set)(编辑属性(get/set))

  • Editing events (add/remove)(编辑事件(add/remove))

  • Editing indexers (square bracket access such as dictionaries)(支持编辑索引器(方括号访问,如字典))

  • Editing operators methods (explicit and implicit operators)(编辑运算符方法(显式和隐式运算符))

  • Editing conversion operators methods such as == and +=(编辑转换运算符方法(如==和+=))

  • Adding/Editing/Removing constructors of classes(加/编辑/删除类的构造函数)

  • Adding/Editing/Removing local functions(添加/编辑/删除本地函数)

  • Changing a method from async to sync, or from sync to async(将方法从异步改为同步,或从同步改为异步)

  • Deleting any methods, properties, fields, class(删除任何方法、属性、字段或类)

  • Adding/editing/removing using directives. E.g. Using UnityEngine(添加/编辑/删除 using 指令(例如:using UnityEngine))

  • Adding/Editing variable initializers. E.g. private int x = 1 in a class
    E.g. int myField = 10. Do note that variables are only initialized when you create a new class instance. We don’t re-run variable initializers for already instantiated classes, as it could break existing code.(添加/编辑变量初始化程序。 例如,类中的私有整数 x = 1。
    例如,整数 myField = 10。请注意,变量仅在创建新类实例时进行初始化。不会为已经实例化的类重新运行变量初始化程序,因为这可能会破坏现有的代码。不可以在运行的时候创建变量)

  • Use of newer C# syntax. Switch expressions, using statements, pattern matching, null coalescing statements, etc. By default, we support all syntax supported by the C# compiler.(支持C#的所有语法)

  • Adding/removing attributes. Note that your code will compile, but System.Reflection won’t pick up on the attribute changes.(添加/移除属性。请注意,您的代码将会编译,但System.Reflection不会捕获属性的更改)

  • Use of nullable anywhere(在任何地方使用可为 null 类型)

  • Adding new methods (添加新方法)

  • Adding, editing, deleting parameters in methods (添加、编辑、删除方法中的参数)

  • Changing the return type of any method. Includes instance, static, properties, events, indexers, generics, etc. (更改任何方法的返回类型,包括实例方法、静态方法、属性、事件、索引器、泛型方法等)

  • Changing accessibility, E.g. changing a method from private to public (更改方法的可访问性,例如,将方法从私有改为公共)

  • Static keyword changes, eg making a method static (更改静态关键字,例如使方法成为静态方法)

  • Renaming methods (重命名方法)

  • Editing generic methods just like normal methods (编辑泛型方法,与普通方法一样)

  • Adding/editing/deleting generic parameters (添加/编辑/删除泛型参数)

  • Adding/editing/deleting the constraint clause of a generic method (E.g. where T : class, new()) (添加/编辑/删除泛型方法的约束子句(例如,where T:class, new()))

  • Adding/replacing/deleting ref, out, in modifiers on arguments (在参数上添加/替换/删除 ref、out、in 修饰符)

  • Editing code marked with [BurstCompile] (编辑带有 [BurstCompile] 标记的代码)

  • Attaching a debugger to modified code in the Unity Editor, including burst compiled code (在Unity编辑器中将调试器附加到已修改的代码,包括 Burst 编译的代码)

  • Attaching a debugger to a Unity Player (On-Device). Supports all code edits just like in the Unity Editor (在Unity Player(设备上)中将调试器附加到已修改的代码,支持与Unity编辑器中一样的代码编辑)

  • Partial coroutine support - changes do apply to newly created coroutines, but ongoing ones won’t update yet (部分协程支持 - 对新创建的协程应用更改,但正在运行的协程尚未更新)

Features on the Roadmap(计划实现)

If you’re using or considering a Business license, and one of these is very important to you, let us know and we’ll prioritize it.

  • Adding, editing, removing fields
  • Adding new classes/structs
  • Adding, editing, removing constructors of structs
  • Adding/editing enums
  • Editing generic class methods
  • Editing variable initializers in partial types
  • Editing a method with return type dynamic, or one of the arguments using dynamic
  • Editing a method body with anonymous types
  • Adding or removing one of the following method keywords: partial, abstract, virtual, override, extern
  • Deleting the constructor of a class doesn’t remove the constructor logic. As a workaround, consider leaving an empty constructor instead of deleting it, and maybe delete the constructor on the next full recompile.
  • Async method that are already executing are not patched - only new invocations will use the updated logic
  • Supporting editing code dynamically generated by libraries like Unity Multiplayer hl-api, Photon, Bolt, Mirror
  • Adding C# files
  • Applying changes to ongoing coroutines

Always Requires a Full Recompile(需要完全编译的东西)

  • Adding, modifying, deleting .asmdef files. Note that scripts inside assembly definitions are supported as you’d expect, only modifications to the .asmdef file itself require a full recompile
  • Modifying define symbols, or other things in .csproj or .sln files
http://www.lryc.cn/news/205740.html

相关文章:

  • 写一个呼吸灯要几行代码?
  • Banana Pi BPI-W3(Armsom W3)RK3588开当板之调试UART
  • LeetCode88——合并两个有序数组
  • C++ BinarySercahTree recursion version
  • 兑换码生成与解析-个人笔记(java)
  • 2023/10/25MySQL学习
  • 网络协议--Ping程序
  • 如何在 Azure 容器应用程序上部署具有 Elastic Observability 的 Hello World Web 应用程序
  • JAVA排序
  • opencalib中lidar2camera安装记录
  • 整个自动驾驶小车001:概述
  • windows本地搭建mmlspark分布式机器平台流程
  • 深入探究 Next.js 中的 getServerSideProps 和 getStaticProps 用法及区别
  • 餐饮业如何高效经营?赶紧闭眼抄这个方法!
  • 餐饮外卖小程序商城的作用是什么
  • nRF52832 SDK15.3.0 基于ble_app_uart demo FreeRTOS移植
  • 电厂数据可视化三维大屏展示平台加强企业安全防范
  • 2246: 【区赛】【宁波32届小学生】最佳交换
  • Java面试记录
  • 【数据库】聚集函数
  • 【单元测试】--编写单元测试
  • ES(elasticsearch) - 三种姿势进行分页查询
  • AQS是什么?AbstractQueuedSynchronizer之AQS原理及源码深度分析
  • 【数据库】函数处理(文本处理函数、日期和时间处理函数、数值处理函数)
  • GEE案例——一个完整的火灾监测案例dNBR差异化归一化烧毁指数
  • 计算机算法分析与设计(20)---回溯法(0-1背包问题)
  • 什么是IO多路复用?Redis中对于IO多路复用的应用?
  • NanoPC-T4 RK3399:DTS之io-domain,FAN
  • vue3+vite+ts项目使用jQuery
  • 一起学数据结构(10)——排序