Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
1
Question by unity_uH_1eZq6Ny1FIA · Sep 27, 2017 at 12:06 AM · uicanvasrecttransform

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): https://i.imgur.com/Yl8LTXB.png

Thanks in advance.

Comment
Add comment · Show 4
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Simon_SG · Sep 27, 2017 at 10:03 AM 0
Share

Hey,

You're not alone, I am having the exact same issue.

I have an array of elements and the first time I set "anchoredposition" and "sizedelta", everything works fine and all elements are positioned and sized correctly.

But the second time when I set the position and size, nothing gets visually updated although when walking through the hierarchy the editor "ui outline" appears in the correct position with the correct size.

As soon I change anything on the object, then suddenly the visual snaps into place...

If you figured something out, please post it here.

Thanks!

avatar image unity_uH_1eZq6Ny1FIA Simon_SG · Sep 27, 2017 at 09:27 PM 0
Share

Unity support has answered me after I filled a bug report. Apparently it's a known issue that's being tackled. They suggested me using Unity Beta.

Another guy who commented in my reddit post said that Unity support suggested deleting Project Settings and Library, but I'm not sure how this'd play out. In any case, here's the thread: https://www.reddit.com/r/Unity3D/comments/72obz8/recttransformanchoredposition_changes_but_element/

avatar image Simon_SG unity_uH_1eZq6Ny1FIA · Sep 28, 2017 at 07:44 AM 0
Share

Hey,

Thanks for the reply, good to know that Unity is aware of it. I currently have gotten around it by doing an ugly hack:

In an Update() in a script, I change the value of the parent (the gameobject that contains all my child objects that refuse to visually update) RectTransform.size$$anonymous$$in by 1 pixel, and reset the value back to what it's supossed to be the next frame.

This seems to force the canvas to recalculate and visually update everything inside.

It's a very ugly way of doing it, but it's the only way so far I've found without changing Unity version.

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by unity_uH_1eZq6Ny1FIA · Sep 28, 2017 at 09:22 PM

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

168 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to offset a RectTransform? 0 Answers

UI Canvas Anchor points are stuck in the bottom left corner and disabled when in overlay mode. 1 Answer

Resize UI Panel to the same size as its parent Canvas through code 0 Answers

How to tell if a RectTransform is within the visible area of a ScrollRect 1 Answer

Updated with UI text element not correct (same frame) 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges