Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnityEngine.Vector3类型, 运算符的报错信息不准确 #1187

Open
SHthemW opened this issue Feb 28, 2025 · 0 comments
Open

UnityEngine.Vector3类型, 运算符的报错信息不准确 #1187

SHthemW opened this issue Feb 28, 2025 · 0 comments

Comments

@SHthemW
Copy link

SHthemW commented Feb 28, 2025

环境

操作系统: 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环境下执行以下代码:

local v = Vector3()
print(nil - v)

得到如下所示的报错:
Image
报错信息提示右操作数出错, 然而在这段代码中实际上是左操作数出错.

问题定位

在UnityEngineVector3Wrap中对运算符的转换似乎输出了固定的报错信息, 没有区分操作符的实际位置:
Image

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant