RectTransform.anchoredPosition changes, but element is not visually updated

I’ve been trying to make a menu that whenever I click in an actor, the menu’s position change so it’s next to the selected actor. The first time (and only the first) I execute the following code, everything works fine:

element.anchoredPosition = screenPosition;

The element is correctly position. However, when I click in another position, the element’s position in the editor CHANGES, but visually it’s the same. Even the buttons inside are clickable in the new position, but Unity keeps showing the element in the older position.

I tried Canvas.ForceUpdateCanvases(), SetActive() and some other stuff, but nothing seems to work.
Here’s an image when seeing from the editor (you can the the selection border shows the new position but the UI is showing on the old one):

Thanks in advance.

Several people have filled a bug report about this issue. There’s some workarounds at the moment:

  • Using position instead of anchoredPosition with a call for GameObject.SetActive(true) in the line before it (Va11ar);
  • Changing RectTransform.sizeMin by 1 pixel at an Update() call and resetting it next frame (Simon_SG)
  • Deleting Project Settings and Library (suggested by Unity Support for Simon_SG, but not tested)

If anyone wants to track the issue and upvote it, just check it out here.