【发布时间】:2018-09-10 14:04:09
【问题描述】:
我正在统一制作游戏,并尝试制作一个 android 滑动控制系统。它与教程中的相同,但不知何故它为我返回错误 - “错误 CS0131 赋值的左侧必须是变量、属性或索引器”。我怎样才能使这段代码工作?
bool isDraging = false;
Vector2 startTouch, swipeDelta = Vector2.zero;
if (isDraging)
{
if (Input.touches.Length > 0)
swipeDelta = Input.touches[0].position = startTouch;
else if(Input.GetMouseButton(0))
(Vector2)Input.mousePosition = startTouch = swipeDelta;
}
【问题讨论】:
-
如您所见from the docs,
mousePosition是只读,因此您不能在else if分支中分配给它。这让我印象深刻XY Problem,你到底想解决什么?可能有更好的方法。