开发何必难为开发,希望您可以点击一下文章头部或尾部的广告支持我一下~ (~ ̄▽ ̄)~ 点击查看详情

东东

error CS1612: Cannot modify a value type return value of `UnityEngine.Transform.position'.
在Gameobject设置坐标位置的报错error CS1612: Cannot modify a value t...
扫描右侧二维码阅读全文
19
2016/06

error CS1612: Cannot modify a value type return value of `UnityEngine.Transform.position'.

屏幕快照 2016-06-19 16.15.26.png

在Gameobject设置坐标位置的报错

error CS1612: Cannot modify a value type return value of `UnityEngine.Transform.position'. Consider storing the value in a temporary variable

报错的代码是这样写的,为了修改x的值

GameObject obj =	GameObject.Find("obj"+i);
obj.transform.position.x = 100.0f;

找了找,应该这样设置才可以

GameObject obj =	GameObject.Find("obj"+i);
Vector3 pos = obj.transform.position;
pos.x = 100.0f;
obj.transform.position = pos;

参考文章

  1. error CS1612: Cannot modify a value type return value of `UnityEngine.Transform.position'.

Last modification:January 1st, 1970 at 08:00 am
您可以点击广告或者直接打赏来支持我
微信公众号

Leave a Comment