Applying prefab with inactive children and TMP element breaks layout

I’m facing a bug with UI + Text Mesh Pro where when i apply a prefab it will break layout settings only if i have UI gameobjects disabled.
Attached is a sample project and here are the reproduction steps:

  1. Unzip the attached project
  2. Open “Main” scene
  3. Go to hierarchy “Canvas → Panel” and disable child gameobject “Button”
  4. Apply prefab
  5. Activate back “Button” gameobject and see that it’s text label is out of position

NOTE: This only happens if Canvas Scaler is set to Constant Physical Size and there is one Text Mesh Pro object in the prefab hierarchy
Use Unity 2017.3.0f2 and TMP from Asset Store

Before applying steps

After applying steps

3320251–258344–TMP_Bug.zip (2.73 MB)

1 Like

This one seems related to what we have in Musicuso project.

1 Like

Could you please also send this as a bug report via the bug reporter?

I have submitted a bug via Unity Bug Reporter prior to this post. Got a reply from the team that does not solve my problem. (Case 977959)
Is that enough?

1 Like

Reply from Unity QA was.
Please try setting the pivot point on the Button to be at the exact center (X 0.5, Y 0.5), this should make the button’s label appear correctly.

That works on the actual example i’ve posted but we don’t always want to have the pivot at that point and it doesn’t clear the fact that there is something there to be fixed. I believe that they are looking into that :slight_smile:

Thanks Unity QA for looking into this :slight_smile:

I have a similar problem but in my case the TMP object is not even related to the prefab (It appears as if a single random TMP instance gets moved to a completely random position). I’ve submitted a bug report, but I’m also rolling back to 2017.2 since this is the third destructive bug I’ve found since upgrading to 2017.3.

1 Like

That also happens to me!
And this bug is still present in Unity2017.3.0f3

Just sharing that I had another user report a similar issue with the TMP Dropdown which appears to be related to object re-parenting. In this particular case, the Scrollbar is placed incorrectly after calling RectTransform.SetParent().

Yes some combination of scrollbar or scrollview with tmp is causing it. Please we need fix for this. M.

Also using an horizontal layout group, is causing some issues on the first element of the group. It keeps resetting the coordinates of the TMP transform after applying the changes to the prefab. (In this case I’m using the paid version of TMP)

TMP is not causing the issue but instead exposing that something related to scene hierarchy and parenting of objects is not behaving correctly in 2017.3.

For instance, while trying to figure out why the Scrollbar of the TMP Dropdown is not in the correct position, I discovered that placing the Scrollbar object in the Template before the Viewport object works correctly. Looking more closely at this reveals that in one case the Anchored Position.x is -80 while in the other it is 0.

I will reach out to the appropriate folks at Unity about this once they are back from the Holidays.

That could be different (not sure) so could you provide me with more details like a scene setup or repro project via PM or Unity bug report?

1 Like

Any short term solutions for this, spent all day repositioning objects that have broken. :frowning:

Another issue is Prefabs have been wiping out any data links that are not within their hierarchy when updating (applying), this has been happening since 2017.1

Had this bug too. It changes position of UI elements inside scene even outside prefab, ui elements in my scene use anchored positioning.
In my case layout breaks with TextMeshProUGUI in hierarchy and enabled CanvasScaler in Canvas. So I disable CanvasScaler and enable it after all prefabs were applied and saved.

1 Like

In my example above you don’t even need any drop-down or layout elements, just having that TMP text in the scene is enough. The particular case I’ve posted is definitely related to TMP since it doesn’t happen if I use UI Text with the exact scene hierarchy.

I tested your example setup in Unity 5.5 thru 2017.3 using the current and previous version of TMP and this behavior can only be observed in Unity 2017.3. In all cases, the Anchored Position of the child object (either the Scrollbar or the Text) gets modified which results in this incorrect behavior.

This is definitely an issue that needs to be addressed. I see a few changes that were made in Unity 2017.3 that could be the source of this new behavior. I’ll talk to the folks who made the changes once they are back from the Holidays.

1 Like

And if possible please write internal test case. :slight_smile:

Hello, another bug case with easy to reproduce project 979554 https://issuetracker.unity3d.com/issues/applying-prefab-with-textmeshprougui-text-changes-position-of-other-ui-elements-when-canvasscaler-is-enabled , its setup uses anchored positioning. Looking forward for patch, thanks.

Any way to get around this while waiting for an update?

Yes. Not applying prefabs :slight_smile: :slight_smile: :slight_smile: :slight_smile:

The behavior also changes if the prefab is disabled in the scene. This is also affected by the CanvasScaler which depending on the change, you could disable before apply.