Search Issue Tracker

Won't Fix

Votes

0

Found in

4.6.0b2

Issue ID

592210

Regression

No

RectTransform.position.Set does not work

UI

-

To reproduce:
1. Open "New Unity Project 52"
2. Open scene test
3. Enter play mode
4. Notice that the position of the button does not change even though a script is setting it to 0,0 every update

Explanation:
This is not a uGUI issue, it's a C# issue. When you call .Set on a Vector2/3 property, you are not setting the property but the value copy of the property. This is any property on any type.

http://answers.unity3d.com/questions/225729/gameobject-positionset-not-working.html

gameObject.position gives you a copy of the position. Calling Set then changes that copy and doesn't affect the property it came from. This is why in C# you typically assign a structure like Vector2/3 like this: "blah.property = new Vector3(0,0,0);"

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.