You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
在Lua中使用UnityEngine.Vector3类型并进行减法运算时, 如果运算符某一侧的操作数类型错误, 则报错信息会输出固定的invalid arguments to right hand of - operator, need UnityEngine.Vector3!, 而非指出实际的操作数位置.
环境
操作系统: Windows10 企业版 LTSC 21H2
Unity版本: 2021.3.9f1
xLua版本: v2.1.15
问题描述
在Lua中使用UnityEngine.Vector3类型并进行减法运算时, 如果运算符某一侧的操作数类型错误, 则报错信息会输出固定的
invalid arguments to right hand of - operator, need UnityEngine.Vector3!
, 而非指出实际的操作数位置.复现路径
在部署了xLua的Unity Lua环境下执行以下代码:
得到如下所示的报错:

报错信息提示右操作数出错, 然而在这段代码中实际上是左操作数出错.
问题定位
在UnityEngineVector3Wrap中对运算符的转换似乎输出了固定的报错信息, 没有区分操作符的实际位置:

手动将代码为修改如下所示, 可正确提示出错操作符的位置

我只是碰巧在Vector3的
-
运算中遇到了这个问题, 不排除其它类型或是其它双目操作符也有类似的问题.因为错误的报错提示, 我消耗了一些时间来分析错误的表达式. 希望能够尽快修复这个问题.
The text was updated successfully, but these errors were encountered: