Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for RectTransform #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Added support for RectTransform #3

wants to merge 1 commit into from

Conversation

ryanmeasel
Copy link

  • The recttransform component throws a warning (as of Unity 4.6) when you set their parent via the transform property transform.parent:

"Parent of RectTransform is being set with parent property. Consider using the SetParent method instead, with the worldPositionStays argument set to false. This will retain local orientation and scale rather than world orientation and scale, which can prevent common UI scaling issues."

  • To circumvent this warning, we check if the parent has a RectTransform
    component and set the boolean worldPositionStays accordingly.
  • Before calling GetComponent on the parent, the parent must be
    checked for existence.
  • Doing so in this manner allows setting the parent transform without changing the local position, rotation or scale. For RectTransform, it also doesn't change the sizeDelta.

- RectTransforms (introduced in Unity 4.6 as part of the new UI
  framework) throw a warning when you set their parent via the transform
  property:

> "Parent of RectTransform is being set with parent property. Consider
using the SetParent method instead, with the worldPositionStays argument
set to false. This will retain local orientation and scale rather than
world orientation and scale, which can prevent common UI scaling
issues."

- To circumvent this warning, we check if the parent has a RectTransform
  component and set the boolean `worldPositionStays` accordingly.
- Before calling `GetComponent` on the parent, the parent must be
  checked for existence.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant