【问题标题】:How do I display a Vector3 to a Text Box?如何将 Vector3 显示到文本框?
【发布时间】:2021-06-03 19:06:55
【问题描述】:

我想在文本框中显示 Vector3,但出现错误。我打印了向量,它给了我 x y 和 z。所以这应该是文本框显示的内容,对吧?但我得到一个错误。我不明白出了什么问题。可以的话请帮忙,谢谢!

local propTextLabel = script:GetCustomProperty("TextLabel"):WaitForObject()

local vector = Vector3.New(10,5,5)
print(vector) --> X=10.000 Y=5.000 Z=5.000
propTextLabel.text = vector --> Error: expected string, received Vector3: (bad argument into 'void(string)')

【问题讨论】:

    标签: vector text properties coregames


    【解决方案1】:

    print() 接受任何对象,因为该函数会自动将任何对象转换为其字符串表示形式。您必须在别处显式地将对象转换为字符串:

    propTextLabel.text = tostring(vector)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-21
      • 1970-01-01
      • 2021-12-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多