C# 无法修改';的返回值;ParticleSystem.shape';因为它不是一个变量
升级我的项目后,我遇到了这个错误。“无法修改'ParticleSystem.shape'的返回值,因为它不是变量”任何人都知道代码有什么问题C# 无法修改';的返回值;ParticleSystem.shape';因为它不是一个变量,c#,unity3d,C#,Unity3d,升级我的项目后,我遇到了这个错误。“无法修改'ParticleSystem.shape'的返回值,因为它不是变量”任何人都知道代码有什么问题 gameObject2.getComponentChildren().shape.radius=objectNode2.GameObject.GetComponent().radius无法更改ParticleSystem.shape的值,因为它实际上不是一个变量。。这是一种财产。返回结构的属性不允许更改该结构的字段 以下代码将提供相同的错误 Vector2
gameObject2.getComponentChildren().shape.radius=objectNode2.GameObject.GetComponent().radius
无法更改ParticleSystem.shape的值,因为它实际上不是一个变量。。这是一种财产。返回结构的属性不允许更改该结构的字段
以下代码将提供相同的错误
Vector2 vec;
Vector2 Vec { get { return vec; } }
void ChangeVecX() { Vec.x = 2; }
有关变量和属性之间差异的更多信息,请参阅本文:
这是你应该做的:
var ps = gameObject2.GetComponentInChildren<ParticleSystem>();
// Copy the value of the property
var newShape = ps.shape;
// Make modifications
newShape.radius = objectNode2.GameObject.GetComponent<CharacterController>().radius;
// Assign the new value to the property
ps.shape = newShape;