C# 属性或索引器不能在此上下文中使用-Unity v2019.3.4f1中出现错误
当我在文本的C# 属性或索引器不能在此上下文中使用-Unity v2019.3.4f1中出现错误,c#,unity3d,game-development,C#,Unity3d,Game Development,当我在文本的z轴上写下根据距离显示分数的代码时,它会显示此消息。 我写道: scoreText.text = player.position.z.toString("0"); 调试时,错误为: The property or indexer 'TextInputBaseField<string>.text' cannot be used in this context because the set accessor is inaccessible [Assembly-CSharp
z轴上写下根据距离显示分数的代码时,它会显示此消息。
我写道:
scoreText.text = player.position.z.toString("0");
调试时,错误为:
The property or indexer 'TextInputBaseField<string>.text' cannot be used in this context because the set accessor is inaccessible [Assembly-CSharp]
无法在此上下文中使用属性或索引器“TextInputBaseField.text”,因为集合访问器不可访问[Assembly CSharp]
请帮帮我,我在网上到处都有。
尊敬。我打赌您使用了错误的UI元素
将第4行从
using UnityEngine.UIElements;
到
然后将scoreText
的类型更改为Text
,因此第8行将是:
public Text scoreText;
不要忘记在编辑器中指定文本
但是如果我错了,而您使用的是正确的
换衣服
scoreText.text
到
问题不大,这只是我的编辑的问题。我使用的Visual Studio代码在版本1.1.4中反复出现问题,我不得不将其降级到版本1.1.3。
如果有人有这个问题,也要这样做。
问候。@ARK69在您完成第一个变体后,到底发生了什么?
scoreText.text
scoreText.value